· 8 years ago · Dec 22, 2017, 05:02 PM
1from kivy.event import EventDispatcher
2from kivy.uix.screenmanager import ScreenManager, Screen
3from kivy.app import App
4from kivy.lang import Builder
5from kivy.metrics import dp
6from kivy.uix.image import Image
7from kivymd.bottomsheet import MDListBottomSheet, MDGridBottomSheet
8from kivymd.button import MDIconButton
9from kivymd.label import MDLabel
10from kivymd.list import ILeftBody, ILeftBodyTouch, IRightBodyTouch
11from kivymd.selectioncontrols import MDCheckbox
12from kivymd.theming import ThemeManager
13from kivymd.dialog import MDDialog
14'''python imports'''
15import sqlite3
16
17
18def __init__():
19 conn = sqlite3.connect('user.db')
20 c = conn.cursor()
21 c.execute("CREATE TABLE IF NOT EXISTS form(name TEXT, password TEXT)")
22 conn.commit()
23
24main_widget_kv = '''
25#:import Toolbar kivymd.toolbar.Toolbar
26#:import ThemeManager kivymd.theming.ThemeManager
27#:import MDNavigationDrawer kivymd.navigationdrawer.MDNavigationDrawer
28#:import NavigationLayout kivymd.navigationdrawer.NavigationLayout
29#:import NavigationDrawerDivider kivymd.navigationdrawer.NavigationDrawerDivider
30#:import NavigationDrawerToolbar kivymd.navigationdrawer.NavigationDrawerToolbar
31#:import NavigationDrawerSubheader kivymd.navigationdrawer.NavigationDrawerSubheader
32#:import MDCheckbox kivymd.selectioncontrols.MDCheckbox
33#:import MDSwitch kivymd.selectioncontrols.MDSwitch
34#:import MDList kivymd.list.MDList
35#:import OneLineListItem kivymd.list.OneLineListItem
36#:import TwoLineListItem kivymd.list.TwoLineListItem
37#:import ThreeLineListItem kivymd.list.ThreeLineListItem
38#:import OneLineAvatarListItem kivymd.list.OneLineAvatarListItem
39#:import OneLineIconListItem kivymd.list.OneLineIconListItem
40#:import OneLineAvatarIconListItem kivymd.list.OneLineAvatarIconListItem
41#:import MDTextField kivymd.textfields.MDTextField
42#:import MDSpinner kivymd.spinner.MDSpinner
43#:import MDCard kivymd.card.MDCard
44#:import MDSeparator kivymd.card.MDSeparator
45#:import MDDropdownMenu kivymd.menu.MDDropdownMenu
46#:import get_color_from_hex kivy.utils.get_color_from_hex
47#:import colors kivymd.color_definitions.colors
48#:import SmartTile kivymd.grid.SmartTile
49#:import MDSlider kivymd.slider.MDSlider
50#:import MDTabbedPanel kivymd.tabs.MDTabbedPanel
51#:import MDTab kivymd.tabs.MDTab
52#:import MDProgressBar kivymd.progressbar.MDProgressBar
53#:import MDAccordion kivymd.accordion.MDAccordion
54#:import MDAccordionItem kivymd.accordion.MDAccordionItem
55#:import MDAccordionSubItem kivymd.accordion.MDAccordionSubItem
56#:import MDThemePicker kivymd.theme_picker.MDThemePicker
57#:import MDBottomNavigation kivymd.tabs.MDBottomNavigation
58#:import MDBottomNavigationItem kivymd.tabs.MDBottomNavigationItem
59
60RelativeLayout:
61 ScreenManager:
62 id: scr_mngr
63
64 Screen:
65 name:'check'
66 MDRaisedButton:
67 text:'check'
68 on_press:app.root.ids.scr_mngr.current = 'newscreen'
69 Screen:
70 name:'newscreen'
71 MDTabbedPanel:
72 MDLabel:
73 font_name: '/storage/emulated/0/Ultra-Regular.ttf'
74 text:'Dashboard'
75 font_size:45
76 pos_hint:{'x':.44, 'y':.45}
77 theme_text_color: 'Secondary'
78
79 Image:
80 source: '/storage/emulated/0/ic_home_3x.png'
81 size_hint: 1, 1
82 pos_hint: {'center_x': 0.5, 'center_y': 0.83}
83
84 MDAccordion:
85 title:'Item 1'
86 #icon: 'home'
87 orientation: 'vertical'
88 size_hint_x: None
89 width: '130dp'
90 text:'Account'
91 MDAccordionItem:
92 title: "App"
93 MDAccordionSubItem:
94 text: "About"
95 on_press:
96 MDAccordionSubItem:
97 text: "Close"
98 on_press:
99 MDAccordionSubItem:
100 text: "Settings"
101 on_press:
102 MDAccordionItem:
103 text: "user"
104 title: 'user'
105
106 MDAccordionSubItem:
107 text: "Login"
108 on_press:app.root.ids.scr_mngr.current = 'screen2'
109 MDAccordionSubItem:
110 text: "Create"
111 on_press:app.root.ids.scr_mngr.current ='screen1'
112
113
114
115
116 MDLabel:
117 text:'Adding home description'
118 pos_hint:{'x':.60,'y':.60}
119 Screen:
120 name: 'screen1'
121
122 MDTabbedPanel:
123 id: tab_panel
124 tab_display_mode:'text'
125
126 MDLabel:
127 text:'Create Account'
128 font_size:45
129 pos_hint:{'x':.44, 'y':.45}
130 font_name: '/storage/emulated/0/Ultra-Regular.ttf'
131 Image:
132 source: '/storage/emulated/0/ic_account_circle_36pt_3x.png'
133 size_hint:.9, .9
134 pos_hint: {'center_x': 0.15, 'center_y': 0.83}
135
136
137
138 MDTextField:
139 text:
140 id:textone
141 text:
142 size_hint_x:.6
143 size_hint_y:.14
144 pos_hint:{'x':.1,'y':.6}
145 MDLabel:
146 text:'Password:'
147 font_size:45
148 pos_hint:{'x':.03, 'y':.01}
149 MDTextField:
150 id:texttwo
151 text:
152 password: True
153 size_hint_x:.6
154 size_hint_y:.14
155 pos_hint:{'x':.1,'y':.51}
156 MDLabel:
157 text:'Password:'
158 font_size:45
159 pos_hint:{'x':.03, 'y':.10}
160
161 MDTextField:
162 id:textthree
163 text:
164 password: True
165 size_hint_x:.6
166 size_hint_y:.14
167 pos_hint:{'x':.1,'y':.4}
168 MDLabel:
169 text:'Name:'
170 font_size:45
171 pos_hint:{'x':.03, 'y':.19}
172
173 MDRaisedButton:
174 size_hint_x:.2
175 size_hint_y:.08
176 pos_hint:{'x':.1,'y':.3}
177 text:'Submit'
178 on_press:app.screenone()
179 md_bg_color: get_color_from_hex(colors['Red']['A400'])
180 MDRaisedButton:
181 pos_hint:{'x':.01,'y':.02}
182 on_press: app.root.ids.scr_mngr.current ='newscreen'
183 size_hint_x:.3
184 size_hint_y:.08
185 text:'Home'
186 pos_hint:{'x':.00,'y':.92}
187 theme_text_color:'ContrastParentBackground'
188 md_bg_color: get_color_from_hex(colors['Yellow']['A400'])
189 Screen:
190
191 id:s2
192 name: 'screen2'
193 MDTabbedPanel:
194 MDLabel:
195 text:'Login'
196 font_size:45
197 pos_hint:{'x':.44, 'y':.45}
198 font_name: '/storage/emulated/0/Ultra-Regular.ttf'
199 Image:
200 source: '/storage/emulated/0/ic_account_circle_36pt_3x.png'
201 size_hint:.9, .9
202 pos_hint: {'center_x': 0.15, 'center_y': 0.83}
203 MDTextField:
204 id:logone
205 text:'Name'
206 size_hint_x:.6
207 size_hint_y:.14
208 pos_hint:{'x':.1,'y':.6}
209 MDTextField:
210 id:logtwo
211 password: True
212 text:'password'
213 size_hint_x:.6
214 size_hint_y:.14
215 pos_hint:{'x':.1,'y':.51}
216 MDRaisedButton:
217 opposite_colors: True
218 size_hint_x:.2
219 size_hint_y:.08
220 pos_hint:{'x':.1,'y':.4}
221 text:'Submit'
222 on_press: root.login(), root.refresher(), root.refresher2()
223 MDRaisedButton:
224 pos_hint:{'x':.01,'y':.92}
225 on_press: app.root.ids.scr_mngr.current = 'newscreen'
226 size_hint_x:.3
227 size_hint_y:.08
228 text:'Home'
229 pos_hint:{'x':.00,'y':.92}
230 theme_text_color:'ContrastParentBackground'
231 md_bg_color: get_color_from_hex(colors['Yellow']['A400'])
232 #CheckBox:
233 #text:'something'
234 #on_active:
235 #pos_hint: {"x":0.2, "y":0.2}
236 #size: sp(32), sp(32)
237
238
239
240
241
242'''
243
244
245class RootWidget():
246 '''This the class representing your root widget.
247 By default it is inherited from ScreenManager,
248 you can use any other layout/widget depending on your usage.
249 '''
250 songname = 0
251 time2 = 0
252 remember2 = .0
253 newlistnew = 15
254 playtime = 0
255 clocks = 0
256 remember = 0
257 new = 0
258 idtestone = 0
259 userinfo = 0
260 clock2 = 0
261 playname = ''
262 volumes = .5
263 healthinfo = ()
264 new = []
265 new2 = []
266
267
268class KitchenSink(App):
269 theme_cls = ThemeManager()
270
271
272
273
274
275 def build(self):
276 main_widget = Builder.load_string(main_widget_kv)
277 # self.theme_cls.theme_style = 'Dark'
278
279
280 return main_widget
281
282 def screenone(self):
283 popup = MDDialog(title='Welcome',
284 content=MDLabel(text='fields must be longer than 6 characters and match '))
285
286
287
288
289
290if __name__ == '__main__':
291 KitchenSink().run()