-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
33 lines (24 loc) · 826 Bytes
/
main.py
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
import tanmatsu
import tests.utils as test
from tanmatsu import widgets
class ButtonList(widgets.List):
class Meta:
border_label = "List"
children = [
widgets.Button(label="Button 1", callback=None),
widgets.Button(label="Button 2", callback=None),
widgets.Button(label="Button 3", callback=None),
]
item_height = 5
class VertSplit(widgets.FlexBox):
text_box = widgets.TextBox(border_label="Text Box", text=test.random_prose())
text_log = widgets.TextLog(border_label="Text Log")
button_list = ButtonList()
class Meta:
flex_direction = widgets.FlexDirection.ROW
with tanmatsu.Tanmatsu(title="Tanmatsu!") as t:
rw = VertSplit()
t.set_root_widget(rw)
for (i, v) in enumerate(rw.button_list.children):
v.callback = lambda i=i: rw.text_log.append_line(f"Button {i + 1} pressed")
t.loop()