-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathWidgetsAEDV.py
377 lines (307 loc) · 11.3 KB
/
WidgetsAEDV.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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.button import Button
from kivy.uix.label import Label
from kivy.uix.image import Image as uixImage
from kivy.loader import Loader
from kivy.uix.spinner import Spinner
from Widget_n import MSLabel
from kivy.uix.gridlayout import GridLayout
from kivy.metrics import cm
import sys
from kivy.uix.checkbox import CheckBox
from kivy.uix.scrollview import ScrollView
from MyLabel import MyLabel
from kivy.clock import Clock
from QueryPopup import QueryPopup
from kivymd.uix.list import MDList
from kivymd.uix.boxlayout import MDBoxLayout
from kivymd.uix.label import MDLabel
from gui import DLabel
from kivymd.uix.textfield import MDTextField
class WidgetsAEDV:
def __init__(self,screenWidgets):
self.sw = screenWidgets
self.gui = self.sw.gui
self.actionType = ""
def startWizard(self,*a):
self.actionType = 'start'
self.buildGuiForAction()
def buildGuiForAction(self):
print("build gui for action ", self.actionType)
if self.actionType == 'start':
bl = MDBoxLayout(
orientation='vertical',
adaptive_height = True,
padding = 3,
spacing = 3
)
#bl.add_widget(MDLabel(text="Widgets wizard"))
#bl.add_widget(Button(
# text="rebuild!",
# on_release=self.sw.rebuildWs
# ))
bl.add_widget(
DLabel(text="Awalable widgets to add to screen:")
)
wl = self.sw.getWidgetsTypeList()
for w in wl:
print("w",w)
bv = MDBoxLayout(
orientation="horizontal",
adaptive_height = True,
padding = 3,
spacing = 3
)
bl.add_widget(bv)
b = Button(
text = w['name'],
#height = self.gui.btH,
size_hint = [None,None],
on_release=self.on_start_addW,
size = [cm(3.0),cm(1.0)]
)
bv.add_widget(b)
ki = uixImage(
source = ("icons/%s"%w['thumb']),
size_hint = [None,None],
#width = cm(3.0),
height = self.gui.btH
)
bv.add_widget(ki)
#bv.add_widget(ki)
print("3")
for c in self.gui.rl.ids.bl_selWidToAdd.children:
self.gui.rl.ids.bl_selWidToAdd.remove_widget(c)
self.gui.rl.ids.bl_selWidToAdd.clear_widgets()
self.gui.rl.ids.bl_selWidToAdd.add_widget(bl)
self.gui.screenChange("SelectWidgetToAdd")
#self.gui.rl.ids.bl_selWidToAdd.size = self.sw.solveScrolSize( self.gui.rl.ids.bl_selWidToAdd )
def getWByName(self,name):
for wi, w in enumerate(self.sw.widgetsTypeList):
if name == w['name']:
return self.sw.widgetsTypeList[wi]
return None
def getWByObj(self, obj):
for si,s in enumerate(self.sw.wConfig):
for wi,w in enumerate(s):
if w['obj'] == obj:
return w,si,wi
return None
def on_start_addW(self,w):
print("on_start_addW",w.text)
self.worikiOnWidgetObj = w
self.gui.on_makeToast("building form ...")
Clock.schedule_once(self.on_start_addWBuildIt,0.01)
def on_start_addWBuildIt(self,*a):
w = self.worikiOnWidgetObj
wName = w.text
self.actionType = "addW %s"%wName
dw = self.getWByName(wName)
print("working on ",dw['obj'])
obj = dw['obj']
self.settingUpWidget = dw
if obj.settingsNeedIt() == False:
print("no need for more steps ")
self.sw.addWidgetOnScreen(dw)
else:
print("it need settings step !")
#self.q1 = QueryPopup()
#self.q1.size_hint = [.8,.97]
bl = MDBoxLayout(
orientation='vertical',
adaptive_height = True,
padding= 3,
spacing= 3,
)
bl.add_widget(DLabel(text="Set it up:"))
bl.add_widget(DLabel(text="Widget settings:"))
bl = obj.addSettingsDialogPart(bl)
srcSett = False
try:
aoeuoeu = obj.wvfh
srcSett = True
except:
pass
if srcSett:
bl.add_widget(DLabel(text="Source settings:"))
bl = obj.wvfh.makeSourceSettingsPart(
bl,
self.gui.sen.sensorsList
)
print("prerun")
#Clock.schedule_once(self.q1.run,0.1)
#self.q1.run()
print("postrun")
print("0predissmiss")
#self.q.dismiss()
print("0postdissmiss")
for c in self.gui.rl.ids.bl_setUpWid.children:
self.gui.rl.ids.bl_setUpWid.remove_widget(c)
self.gui.rl.ids.bl_setUpWid.clear_widgets()
self.gui.rl.ids.bl_setUpWid.add_widget(bl)
self.gui.screenChange("SettingUpWidget")
#self.gui.rl.ids.bl_setUpWid.size = self.sw.solveScrolSize( self.gui.rl.ids.bl_setUpWid )
def on_widgetSetUpDone(self,a='',b=''):
print("on_widgetSetUpDone")
print("settingUpWidget",self.settingUpWidget)
o = self.settingUpWidget
obj = o['obj']
srcSett = False
wvfh = 'direct'
try:
aoeuoeu = obj.wvfh
srcSett = True
except:
print("wobj don't have wvfh",o['objName'])
pass
if srcSett:
wvfh = obj.wvfh.getSettingsFromWidgetsToDict()
atr = obj.getAttrFromDialog()
print("atr",atr)
print("wvfh",wvfh)
if wvfh == 0:
print("EE - no src or chn selected !")
return 0
#sys.exit(9)
if srcSett:
callback = wvfh['callback']
else:
callback = obj.getCallbacks()
#sys.exit()
if len(self.sw.wConfig)<=self.sw.screen:
print("adding first widget on screen !",self.sw.screen)
self.sw.wConfig.append([])
self.sw.wConfig[self.sw.screen].append({
'name': o['name'],
'obj': o['obj'],
'objName': o['objName'],
'callback': callback,
'atr':atr,
'valHandler': wvfh,
'pos': [0.1,0.1],
'rotation' : 0.0,
'scale': 1.0
})
wi = len(self.sw.wConfig[self.sw.screen])-1
print("-----------------------------------")
print(self.sw.wConfig)
self.sw.saveConfig()
#sys.exit(9)
#tScreen = self.sw.screen
#self.sw.rebuildWs()
self.sw.fromWConfigBuildWidget(
self.sw.screen,
wi,
self.sw.fls[self.sw.screen]
)
self.sw.gui.screenChange(("Widgets%s"%self.sw.screen))
def on_next_setup_widget(self):
print("on_next_setup_widget")
self.actionType = "step2"
def on_start_remove(self):
print("on_start_remove TODO")
def startEditWizard(self):
print("startEditWizard")
obj = self.sw.wConfig[
self.sw.widgetEdit['screen']
][
self.sw.widgetEdit['wi']
]['obj']
print("""screen {} wi {} obj{} all wConf{}""".format(
self.sw.widgetEdit['screen'],
self.sw.widgetEdit['wi'],
obj,
self.sw.wConfig[
self.sw.widgetEdit['screen']
][
self.sw.widgetEdit['wi']
]
))
if obj.settingsNeedIt() == False:
print("no need for more steps ")
q = QueryPopup()
q.setAction(
"Widget edit",
"This widget don't have a settings :/",
None, "OK",
None, None)
q.run()
else:
self.actionType = 'edit'
self.on_start_editW()
def on_start_editW(self):
print("on_start_editW")
si = self.sw.widgetEdit['screen']
wi = self.sw.widgetEdit['wi']
inWConf = self.sw.wConfig[si][wi]
obj = inWConf['obj']
if inWConf != None:
print("GOT Widget !",inWConf)
#obj = inWConf['obj']
bl = MDBoxLayout(
orientation='vertical',
adaptive_height = True,
padding = 3,
spacing = 3
)
bl.add_widget(DLabel(text="Widget edit"))
bl.add_widget(DLabel(text="Widget Settings:"))
bl = obj.addSettingsDialogPart(bl,inWConf)
#sys.exit()
srcSett = False
try:
aoeuoeu = obj.wvfh
srcSett = True
except:
pass
if srcSett:
l1 = DLabel(text="Source settings:")
bl.add_widget(l1)
bl = obj.wvfh.makeSourceSettingsPart(
bl,
self.gui.sen.sensorsList,
inWConf
)
for c in self.gui.rl.ids.bl_EditWid.children:
self.gui.rl.ids.bl_EditWid.remove_widget(c)
self.gui.rl.ids.bl_EditWid.clear_widgets()
self.gui.rl.ids.bl_EditWid.add_widget(bl)
self.gui.screenChange("EditWidget")
#self.gui.rl.ids.bl_EditWid.size = self.sw.solveScrolSize(
# self.gui.rl.ids.bl_EditWid
# )
def on_editDoneSaveSettings(self):
print("on_editDoneSaveSettings")
si = self.sw.widgetEdit['screen']
wi = self.sw.widgetEdit['wi']
obj = self.sw.getWeObj( si, wi )
inWConf = self.sw.wConfig[si][wi]
srcSett = False
wvfh = 'direct'
try:
aoeuoeu = obj.wvfh
srcSett = True
except:
pass
if srcSett:
wvfh = obj.wvfh.getSettingsFromWidgetsToDict()
atr = obj.getAttrFromDialog()
print("atr",atr)
print("wvfh",wvfh)
if srcSett:
callback = wvfh['callback']
else:
callback = obj.getCallbacks()
screen = self.sw.screen
self.sw.cleanAll()
print("inWConfig",inWConf)
#sys.exit()
self.sw.wConfig[si][wi]['callback'] = callback
self.sw.wConfig[si][wi]['atr'] = atr
self.sw.wConfig[si][wi]['valHandler'] = wvfh
print("inWConfig after change!",inWConf)
tScreen = self.sw.screen
self.sw.buildW()
self.gui.screenChange(("Widgets%s"%tScreen))
self.sw.updateIt()
#sys.exit()