Repository navigation
Expand file tree
/
Copy pathicons.py
More file actions
61 lines (50 loc) · 1.84 KB
/
Copy pathicons.py
File metadata and controls
61 lines (50 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import pyui
class SearchView(pyui.View):
# Separate state since live-searching is slow.
current_text = pyui.State(default="")
def __init__(self, search_binding):
super().__init__()
self.search_binding = search_binding
def search(self, text=None):
self.search_binding.value = self.current_text.value
def content(self):
yield pyui.HStack()(
pyui.TextField(
self.current_text, placeholder="Search icons", action=self.search
),
pyui.Button("Search", action=self.search, asset="button.primary").priority(
"high"
),
).padding(10)
class IconsView(pyui.View):
search_text = pyui.State(default="")
def filtered_icons(self):
search = self.search_text.value.lower()
for name in pyui.Icon.data["icons"]:
if search == "" or search in name:
yield name
def content(self):
yield pyui.VStack(spacing=0)(
SearchView(self.search_text),
pyui.ScrollView()(
pyui.Grid(size=100, flex=True)(
pyui.ForEach(
self.filtered_icons(),
lambda name: (
pyui.Rectangle(
pyui.VStack()(
pyui.Icon(name, size=32),
pyui.Text(name).font(size=11),
)
)
.background(30, 30, 30)
.padding(5)
),
)
).position(pyui.Position.TOP_LEADING)
),
)
if __name__ == "__main__":
app = pyui.Application("io.temp.IconViewer")
app.window("Icon Viewer", IconsView())
app.run()