-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample_rawframework_various.py
More file actions
executable file
·58 lines (53 loc) · 1.72 KB
/
example_rawframework_various.py
File metadata and controls
executable file
·58 lines (53 loc) · 1.72 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
#!/usr/bin/env python3
from boldui import Oplist, Expr, var, stringify_op, ProtocolServer
from boldui.framework import Clear, Column, Padding, Center, SizedBox, Rectangle, Text, Flexible
def main():
root = Clear(
color=0xff202030,
child=Column([
Padding(
Text(
'Hello, World!',
font_size=18,
color=0xffa0a0a0,
),
all=10,
),
Padding(
Center(
SizedBox(
Rectangle(0xffa0a0a0),
width=abs((var('time') % 1) - 0.5) * 50 + 100,
height=abs(((var('time') + 0.5) % 1) - 0.5) * 50 + 100,
),
),
all=10,
),
Padding(
Rectangle(
color=Expr.if_(var('height') > 600, 0xffa0a0a0, 0xff9090d0)
),
all=10
),
Flexible(
Padding(
Rectangle(
color=Expr.if_(var('width') > 800, 0xffa0a0a0, 0xffd09090)
),
all=10
),
flex_x=3,
),
]),
)
built_root = root.build()
oplist = Oplist()
size = built_root.layout(Expr(0), Expr(0), var('width'), var('height'))
scene = built_root.render(oplist, Expr(0), Expr(0), size[0], size[1])
for op in scene:
print(stringify_op(op))
server = ProtocolServer("/tmp/boldui.hello_world.sock")
server.scene = {'oplist': oplist.to_list(), 'scene': scene, 'vars': {}}
server.serve()
if __name__ == '__main__':
main()