Skip to content

Commit 01d10ac

Browse files
committed
feat: adding Button2D
feat: adding Button2D temp: changes fix: updating buton to be reactive fix: update button icons on states fix: moving actual buttons to elements chore: adding button tests
1 parent 8bb525c commit 01d10ac

File tree

8 files changed

+1202
-670
lines changed

8 files changed

+1202
-670
lines changed

docs/examples/_valid_examples.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ files = [
4949
"viz_panel.py",
5050
"viz_textblock.py",
5151
"viz_sliders.py",
52+
"viz_button.py",
5253
]
5354

5455
[animation]

docs/examples/viz_button.py

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
"""
2+
========
3+
Button2D
4+
========
5+
"""
6+
7+
##############################################################################
8+
# First, a bunch of imports
9+
10+
from fury.ui import TexturedButton2D, TextButton2D
11+
from fury.window import (
12+
Scene,
13+
ShowManager,
14+
)
15+
from fury.data import fetch_viz_icons, read_viz_icons
16+
17+
##############################################################################
18+
# Fetch icons that are included in FURY.
19+
20+
fetch_viz_icons()
21+
22+
##############################################################################
23+
# Creating a Scene
24+
25+
scene = Scene()
26+
27+
#############################################################################
28+
# Creating a Button with multiple icons
29+
30+
btn = TextButton2D(
31+
label="Hello",
32+
size=(100, 100),
33+
position=(150, 350),
34+
states={
35+
"hover": {"text": "hover", "color": (0.9, 0.9, 0.9)},
36+
"pressed": {"text": "pressed", "color": (0.6, 0.6, 0.6)},
37+
"disabled": {"text": "disabled", "color": (0.1, 0.1, 0.1)},
38+
"default": {"text": "default", "color": (1, 1, 1)},
39+
},
40+
)
41+
scene.add(btn)
42+
43+
btn = TexturedButton2D(
44+
states={
45+
"hover": read_viz_icons(fname="circle-up.png"),
46+
"pressed": read_viz_icons(fname="circle-down.png"),
47+
"disabled": read_viz_icons(fname="circle-left.png"),
48+
"default": read_viz_icons(fname="circle-right.png"),
49+
},
50+
size=(100, 100),
51+
position=(450, 350),
52+
)
53+
scene.add(btn)
54+
###############################################################################
55+
# Starting the ShowManager
56+
57+
if __name__ == "__main__":
58+
current_size = (700, 700)
59+
show_manager = ShowManager(
60+
scene=scene,
61+
size=current_size,
62+
title="FURY 2.0: Button2D Example",
63+
)
64+
show_manager.start()

fury/data/fetcher.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
UW_RW_URL = "https://digital.lib.washington.edu/researchworks/bitstream/handle/"
2929

3030
NEW_ICONS_DATA_URL = (
31-
"https://raw.githubusercontent.com/fury-gl/fury-data/master/icons/" "new_icons/"
31+
"https://raw.githubusercontent.com/fury-gl/fury-data/master/icons/new_icons/"
3232
)
3333

3434
CUBEMAP_DATA_URL = (
@@ -296,13 +296,13 @@ def fetcher():
296296
if split_ext[-1] == ".gz" or split_ext[-1] == ".bz2":
297297
if os.path.splitext(split_ext[0])[-1] == ".tar":
298298
ar = tarfile.open(pjoin(folder, f))
299-
ar.extractall(path=folder)
299+
ar.extractall(path=folder, filter="data")
300300
ar.close()
301301
else:
302302
raise ValueError("File extension is not recognized")
303303
elif split_ext[-1] == ".zip":
304304
z = zipfile.ZipFile(pjoin(folder, f), "r")
305-
z.extractall(folder)
305+
z.extractall(folder, filter="data")
306306
z.close()
307307
else:
308308
raise ValueError("File extension is not recognized")
@@ -570,8 +570,7 @@ def fetch_gltf(*, name=None, mode="glTF"):
570570
"702EE8713994243C8619A29C9ECE32F95305737F583B747C307500F3EC4A6B56",
571571
"044917A8FBD0EB980D93B6C406A577BEA416FA934E897C26C87E91C218EF4432",
572572
],
573-
doc="Download the following wiki information"
574-
"Interdisciplinary map of the journals",
573+
doc="Download the following wiki informationInterdisciplinary map of the journals",
575574
msg=(
576575
"More information about complex "
577576
"networks can be found in this papers:"

fury/ui/__init__.pyi

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ __all__ = [
77
"Rectangle2D",
88
"Disk2D",
99
"TextBlock2D",
10-
# "Button2D",
11-
# "TextBox2D",
10+
"TexturedButton2D",
11+
"TextButton2D",
1212
"LineSlider2D",
13+
# "TextBox2D",
1314
# "LineDoubleSlider2D",
1415
# "RingSlider2D",
1516
# "RangeSlider",
@@ -47,7 +48,7 @@ __all__ = [
4748
from .containers import Panel2D
4849
from .context import UIContext
4950
from .core import UI, Anchor, Disk2D, Rectangle2D, TextBlock2D
50-
from .elements import LineSlider2D
51+
from .elements import LineSlider2D, TextButton2D, TexturedButton2D
5152

5253
# from .elements import (
5354
# Card2D,

0 commit comments

Comments
 (0)