Skip to content

Commit 862ddda

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 e63bdbc commit 862ddda

File tree

8 files changed

+1965
-1619
lines changed

8 files changed

+1965
-1619
lines changed

docs/examples/_valid_examples.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ files = [
4848
"viz_shapes.py",
4949
"viz_panel.py",
5050
"viz_textblock.py",
51+
"viz_button.py",
5152
]
5253

5354
[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 = (
@@ -278,13 +278,13 @@ def fetcher():
278278
if split_ext[-1] == ".gz" or split_ext[-1] == ".bz2":
279279
if os.path.splitext(split_ext[0])[-1] == ".tar":
280280
ar = tarfile.open(pjoin(folder, f))
281-
ar.extractall(path=folder)
281+
ar.extractall(path=folder, filter="data")
282282
ar.close()
283283
else:
284284
raise ValueError("File extension is not recognized")
285285
elif split_ext[-1] == ".zip":
286286
z = zipfile.ZipFile(pjoin(folder, f), "r")
287-
z.extractall(folder)
287+
z.extractall(folder, filter="data")
288288
z.close()
289289
else:
290290
raise ValueError("File extension is not recognized")
@@ -552,8 +552,7 @@ def fetch_gltf(*, name=None, mode="glTF"):
552552
"702EE8713994243C8619A29C9ECE32F95305737F583B747C307500F3EC4A6B56",
553553
"044917A8FBD0EB980D93B6C406A577BEA416FA934E897C26C87E91C218EF4432",
554554
],
555-
doc="Download the following wiki information"
556-
"Interdisciplinary map of the journals",
555+
doc="Download the following wiki informationInterdisciplinary map of the journals",
557556
msg=(
558557
"More information about complex "
559558
"networks can be found in this papers:"

fury/ui/__init__.pyi

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ __all__ = [
77
"Rectangle2D",
88
"Disk2D",
99
"TextBlock2D",
10-
# "Button2D",
10+
"TexturedButton2D",
11+
"TextButton2D",
1112
# "TextBox2D",
1213
# "LineSlider2D",
1314
# "LineDoubleSlider2D",
@@ -46,7 +47,14 @@ __all__ = [
4647

4748
from .containers import Panel2D
4849
from .context import UIContext
49-
from .core import UI, Anchor, Disk2D, Rectangle2D, TextBlock2D
50+
from .core import (
51+
UI,
52+
Anchor,
53+
Disk2D,
54+
Rectangle2D,
55+
TextBlock2D,
56+
)
57+
from .elements import TextButton2D, TexturedButton2D
5058

5159
# from .elements import (
5260
# Card2D,

0 commit comments

Comments
 (0)