-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathflet-lorem.py
80 lines (67 loc) · 1.99 KB
/
flet-lorem.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
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# Flet Lorem Ipsum Generator - Hololeo Labs
import flet
from flet import Page, Row, Column, Text, TextField, Slider, Dropdown
from flet import dropdown, padding
def main(page: Page):
page.title = "Flet Lorem Ipsum Generator - Hololeo Labs"
page.window_always_on_top = True
page.bgcolor = "#262d2f"
page.vertical_alignment = "start"
page.padding = 10
def update_lorem ():
#s = lorem.createText (dd.value,int(tf.value))
s = "asdf"
t2.value = s
page.update()
def dropdown_changed(e):
update_lorem()
def tf_on_changed (e):
try:
val = int(e.control.value)
if val > 99:
val = 99
tf.value = val
update_lorem()
except:
print ("num textfield not number")
tf.value = 3
tf = TextField (
label="",
keyboard_type = "number",
value = 3,
max_lines=1,
min_lines=1,
width=50,
on_submit = tf_on_changed,
on_blur = tf_on_changed
)
dd = Dropdown(
on_change=dropdown_changed,
value = "Paragraph",
options=[
dropdown.Option("Word"),
dropdown.Option("Sentence"),
dropdown.Option("Paragraph"),
],
width=200,
)
page.header = Text (
value = "Flet Lorem Ipsum Generator",
size = 25
)
page.ui_row = Row ([tf,dd])
page.output = TextField (
label="",
keyboard_type = "number",
value = "Sit et, elit facilisi elit tempus fermentum ipsum ipsum ipsum maecenas nec at enim arcu molestie nibh."*1000,
content_padding = padding.only (right=20),
border_width = 2,
max_lines=100,
min_lines=10,
expand = True,
read_only = True
)
page.add (Column ([page.header, page.ui_row, page.output], expand= True))
page.update()
flet.app(target=main, port=7777)
#flet.app(target=main, port=7777, view=flet.WEB_BROWSER)