-
Notifications
You must be signed in to change notification settings - Fork 26
/
demo.py
211 lines (181 loc) · 6 KB
/
demo.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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
from kivy.uix.widget import Widget
from kivy.lang import Builder
from flat_kivy.flatapp import FlatApp
from flat_kivy.uix.flattextinput import FlatTextInput
Builder.load_string('''
<RootWidget>:
GridLayout:
cols: 3
pos: root.pos
size: root.size
padding: '5dp'
spacing: '5dp'
canvas.before:
Color:
rgb: 1,1,1
Rectangle:
pos: self.pos
size: self.size
FlatButton:
text: 'button'
theme: ('green', 'accent')
FlatIconButton:
text: 'icon button'
icon: 'fa-tree'
theme: ('green', 'accent')
FlatToggleButton:
text: 'toggle button'
group: 'toggle'
theme: ('green', 'accent')
RaisedFlatToggleButton:
text: 'raised toggle button'
group: 'toggle'
theme: ('green', 'accent')
FlatCheckBoxListItem:
text: 'check 1'
group: 'check'
theme: ('green', 'accent')
FlatCheckBoxListItem:
text: 'check 2'
group: 'check'
theme: ('green', 'accent')
FlatCard:
image_source: 'flat_kivy/AstroPic1.jpg'
text: 'the card'
color_tuple: ('Gray', '0000')
FlatTextInput:
BoxLayout:
orientation: 'vertical'
FlatLabel:
text: 'FlatScrollView'
size_hint_y: None
height: '35dp'
theme: ('green', 'main')
FlatScrollView:
do_scroll_x: False
BoxLayout:
orientation: 'vertical'
height: '400dp'
size_hint_y: None
FlatLabel:
text: '1'
FlatLabel:
text: '2'
FlatLabel:
text: '3'
FlatLabel:
text: '4'
FlatLabel:
text: '5'
FlatLabel:
text: '6'
RaisedFlatButton:
text: 'popup'
theme: ('green', 'accent')
on_release: popup_demo.open()
popup_demo: popup_demo.__self__
FlatPopup:
id: popup_demo
title: 'Flat Popup Demo'
size_hint: .6,.6
on_parent: if self.parent: self.parent.remove_widget(self)
BoxLayout:
spacing: '5dp'
padding: '5dp'
RaisedFlatButton:
text: 'just a button in here'
theme: ('green', 'main')
RaisedFlatButton:
text: 'just a button in here'
theme: ('green', 'main')
FlatSlider:
id: hor_slider
orientation: 'horizontal'
min: 10
value: ver_slider.value
theme: ('green', 'main')
FlatSlider:
id: ver_slider
orientation: 'vertical'
min: 10
value: hor_slider.value
theme: ('green', 'main')
FlatSlider:
value: hor_slider.value
orientation: 'horizontal'
disabled: True
theme: ('green', 'main')
''')
class RootWidget(Widget):
pass
class MyFlatApp(FlatApp):
def build(self):
return RootWidget()
def setup_themes(self):
main = {
'FlatButton': {
'color_tuple': ('Gray', '0000'),
'font_color_tuple': ('LightGreen', '800'),
'style': 'Button',
},
'RaisedFlatButton': {
'color_tuple': ('Gray', '0000'),
'font_color_tuple': ('LightGreen', '800'),
'style': 'Button',
},
'FlatLabel': {
'style': 'Button',
},
'FlatSlider': {
'bar_fill_color_tuple': ('LightGreen', '500'),
'handle_accent_color_tuple': ('LightGreen', '200'),
}
}
accent = {
'FlatButton': {
'color_tuple': ('LightGreen', '500'),
'font_color_tuple': ('Gray', '1000'),
'style': 'Button',
},
'RaisedFlatButton': {
'color_tuple': ('LightGreen', '500'),
'font_color_tuple': ('Gray', '1000'),
'style': 'Button',
},
'FlatIconButton': {
'color_tuple': ('LightGreen', '500'),
'font_color_tuple': ('Gray', '1000'),
'style': 'Button',
'icon_color_tuple': ('Gray', '1000')
},
'FlatToggleButton': {
'color_tuple': ('LightGreen', '500'),
'font_color_tuple': ('Gray', '1000'),
'style': 'Button',
},
'RaisedFlatToggleButton': {
'color_tuple': ('LightGreen', '500'),
'font_color_tuple': ('Gray', '1000'),
'style': 'Button',
},
'FlatCheckBox': {
'color_tuple': ('Gray', '0000'),
'check_color_tuple': ('LightGreen', '500'),
'outline_color_tuple': ('Gray', '1000'),
'style': 'Button',
'check_scale': .7,
'outline_size': '10dp',
},
'FlatCheckBoxListItem': {
'font_color_tuple': ('Gray', '1000'),
'check_color_tuple': ('LightGreen', '500'),
'outline_color_tuple': ('Gray', '800'),
'style': 'Button',
'check_scale': .7,
'outline_size': '10dp',
},
}
self.theme_manager.add_theme('green', 'main', main)
self.theme_manager.add_theme('green', 'accent', accent)
if __name__ == '__main__':
MyFlatApp().run()