-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
148 lines (141 loc) · 4.89 KB
/
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
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
import flet as ft
import random
def main(page: ft.Page):
#List Quotes, colors
quotes = [
{
"content": "Without freedom of thought, there can be no such thing as wisdom - and no such thing as public liberty without freedom of speech.",
"author": "Benjamin Franklin",
},
{
"content": "We cannot do everything at once, but we can do something at once.",
"author": "Calvin Coolidge",
},
{
"content": "Your big opportunity may be right where you are now.",
"author": "Napoleon Hill",
},
{
"content": "There is more wisdom in your body than in your deepest philosophy.",
"author": "Friedrich Nietzsche",
},
{
"content": "If you smile when no one else is around, you really mean it.",
"author": "Andy Rooney",
},
{
"content": "Well done is better than well said.",
"author": "Benjamin Franklin",
},
{
"content": "Every artist dips his brush in his own soul, and paints his own nature into his pictures.",
"author": "Henry Ward Beecher",
},
{
"content": "A good head and a good heart are always a formidable combination.",
"author": "Nelson Mandela",
},
{
"content": "The supreme art of war is to subdue the enemy without fighting.",
"author": "Sun Tzu",
},
{
"content": "Friendship always benefits; love sometimes injures.",
"author": "Seneca the Younger",
},
{
"content": "Inspiration exists, but it has to find us working.",
"author": "Pablo Picasso",
},
{
"content": "If you are out to describe the truth, leave elegance to the tailor.",
"author": "Albert Einstein",
},
{
"content": "There is no friendship, no love, like that of the parent for the child.",
"author": "Henry Ward Beecher",
},
{
"content": "Every great dream begins with a dreamer. Always remember, you have within you the strength, the patience, and the passion to reach for the stars to change the world.",
"author": "Harriet Tubman",
},
{
"content": "If the shoe doesn't fit, must we change the foot?",
"author": "Gloria Steinem",
},
]
colors = [
"#FFD81B60",
"#FFE53935",
"#FFFB8C00",
"#FFFFA000",
"#FF7CB342",
"#FF43A047",
"#FF00897B",
"#FF00ACC1",
"#FF039BE5",
"#FF1E88E5",
"#FF3949AB",
"#FF8E24AA",
]
#Inicial values
page.title = "Random Quote Machine"
page.vertical_alignment = ft.MainAxisAlignment.CENTER
page.horizontal_alignment = ft.CrossAxisAlignment.CENTER
page.bgcolor="#FFD81B60"
txt_content = ft.Text(
value="❝ There is no friendship, no love, like that of the parent for the child.",
text_align=ft.TextAlign.RIGHT,
width=600,
size=25,
color="#FFD81B60"
)
txt_author = ft.Text(
value="- Henry Ward Beecher",
text_align=ft.TextAlign.RIGHT,
width=200,
size=20,
color="#FFD81B60"
)
#Function generate new Quote
def new_quote(e):
randomColor = random.randrange(0, len(colors))
randomIndex = random.randrange(0, len(quotes))
txt_content.value = "❝ " + str(quotes[randomIndex]["content"])
txt_author.value = "- " + str(quotes[randomIndex]["author"])
page.bgcolor=colors[randomColor]
txt_content.color=colors[randomColor]
txt_author.color=colors[randomColor]
page.update()
#Create Container
container = ft.Container(
bgcolor=ft.colors.WHITE,
height=350,
width=700,
padding=30,
border_radius=15,
content=ft.Column(
[
txt_content,
ft.Container(height=30),
txt_author,
ft.Container(height=10),
ft.ElevatedButton(
"new Quote",
on_click=new_quote,
height=50,
style=ft.ButtonStyle(
color={
ft.MaterialState.HOVERED: ft.colors.AMBER,
ft.MaterialState.DEFAULT: ft.colors.WHITE,
},
),
),
],
alignment=ft.MainAxisAlignment.CENTER,
horizontal_alignment=ft.CrossAxisAlignment.END,
),
)
page.add(container)
page.update()
ft.app(target=main,view="web_browser")