-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample_framework_counter.py
More file actions
executable file
·53 lines (45 loc) · 1.42 KB
/
example_framework_counter.py
File metadata and controls
executable file
·53 lines (45 loc) · 1.42 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
#!/usr/bin/env python3
from boldui.adwaita import Button
from boldui.app import App, update_widget
from boldui.framework import Row, Rectangle, SizedBox, Text, Center, Stack, Widget
class MainPage(Widget):
def __init__(self):
self.counter = 0
super(MainPage, self).__init__()
def build(self):
def dec(_):
self.counter -= 1
update_widget()
def inc(_):
self.counter += 1
update_widget()
return Stack([
# Background
Rectangle(color=0xff242424),
# Counter
Center(
Row([
SizedBox(
width=41, height=41,
child=Button(
Text(text='-', font_size=18),
on_mouse_down=dec,
),
),
SizedBox(
width=60, height=41,
child=Text(text=str(self.counter), font_size=18)
),
SizedBox(
width=41, height=41,
child=Button(
Text(text='+', font_size=18),
on_mouse_down=inc,
),
),
]),
),
])
if __name__ == '__main__':
app = App(MainPage)
app.run()