-
Notifications
You must be signed in to change notification settings - Fork 0
/
Bonierungsprogramm8.py
692 lines (507 loc) · 30.2 KB
/
Bonierungsprogramm8.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
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import kivy
kivy.require('1.1.3')
import os
import pickle
import gc
from kivy.garden.filechooserthumbview import *
from kivy.factory import Factory
from kivy.properties import ObjectProperty, StringProperty, ListProperty
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.floatlayout import FloatLayout
from kivy.uix.gridlayout import GridLayout
from kivy.uix.stacklayout import StackLayout
from kivy.uix.relativelayout import RelativeLayout
from kivy.uix.widget import Widget
from kivy.uix.carousel import Carousel
from kivy.uix.label import Label
from kivy.uix.button import Button
from kivy.uix.textinput import TextInput
from kivy.uix.scatter import Scatter
from kivy.uix.togglebutton import ToggleButton
from kivy.uix.spinner import Spinner
from kivy.uix.dropdown import DropDown
from kivy.uix.popup import Popup
from kivy.uix.scrollview import ScrollView
from kivy.graphics import Color, Rectangle
from screenmanager import CustomScreenManager, CustomScreen
from customscrollviewpopup import CustomScrollviewPopupContent, CustomButton2
from produktorganizer import ProduktOrganizer, PopupBildAuswaehlenProduktorganizer, CustomScrollviewItem, CustomScrollviewProduktOrganizer
#from kivy.lang import Builder
#Builder.load_file('screenmanager.kv')
class LoginScreen(FloatLayout):
#x = ListProperty([])
#print x
def __init__(self, **kwargs):
super(LoginScreen, self).__init__(**kwargs)
#gc.disable()
self.DropdownObjects = []
self.add_widget(Label(text= "Wilkommen [color=ff3333] [sub] bei der [/sub][/color][color=3333ff][b] Bonierungs[sup][color=#098125ff]App[/sup][/b][/color]",
markup = True, pos_hint={'top': 1.2}, font_size='20sp'))
self.GridlayoutS1 = GridLayout(cols = 2, size_hint_y = 1/5, pos_hint={'top': 0.6})
self.add_widget(self.GridlayoutS1)
self.GridlayoutS1.add_widget(Label(text='User Name')) #, size_hint_x = 0.2, size_hint_y = 0.2))
self.username = TextInput(multiline=False) #, size_hint_x = 0.2, size_hint_y = 0.2)
self.username.bind(on_text_validate=self.on_enter)
self.GridlayoutS1.add_widget(self.username)
self.GridlayoutS1.add_widget(Label(text='password')) #,size_hint_x = 0.2, size_hint_y = 0.2))
self.password = TextInput(password=True, multiline=False) #, size_hint_x = 0.2, size_hint_y = 0.2)
self.GridlayoutS1.add_widget(self.password)
self.BenutzerListe = {"": ""};
self.add_widget(Button(text='Einloggen', size_hint_y= 1/5, pos_hint={'top': 0.4}, on_release = self.AbfrageLogin))
self.LabelLoginanzeiger = Label(size_hint_y= 1/5)
self.add_widget(self.LabelLoginanzeiger)
def on_enter(self, instance):
print('User pressed enter in', instance)
self.password.focus = True
def AbfrageLogin(self, widget):
Username = self.username.text
Passwort = self.password.text
if Username in self.BenutzerListe and Passwort == self.BenutzerListe[Username]:
self.LabelLoginanzeiger.text = 'Login korrekt'
self.clear_widgets()
self.HauptProgramm()
else:
self.LabelLoginanzeiger.text = 'Login inkorrekt'
def HauptProgramm(self, *args):
print 'das ist das Hauptprogramm'
self.BilderListeVorlaeufer = []
self.BilderListeVorlaeufer = os.listdir(os.getcwd() + '/pictures')
self.Pfade = []
for i in self.BilderListeVorlaeufer:
Pfad = os.path.join('pictures', i)
if os.path.isfile(Pfad) == True:
self.Pfade.append(Pfad)
self.HauptCarousel = Carousel(scroll_timeout = 100)
App.Pfade = self.Pfade
self.add_widget(self.HauptCarousel)
####################################################################################################
### Erste Seite im HauptCarousel momentan mit den produktbildern
self.HauptCarousel.FloatLayout = FloatLayout()
self.HauptCarousel.add_widget(self.HauptCarousel.FloatLayout)
self.HauptCarousel.FloatLayout.GridLayout = GridLayout(cols=3, pos_hint={'x': 0,'y': 0}, size_hint=[1,0.9])
self.HauptCarousel.FloatLayout.add_widget(self.HauptCarousel.FloatLayout.GridLayout)
for i in range(9):
button = Button(background_normal = self.Pfade[i], background_down= 'bilder_oberflaeche/1361740537_Ball Green_mitHaken.png', mipmap= True)
self.HauptCarousel.FloatLayout.GridLayout.add_widget(button)
## self.HauptCarousel.FloatLayout.GridLayout.add_widget(Button(text='test'))
## self.HauptCarousel.FloatLayout.GridLayout.add_widget(Button(text='test2'))
#####################################################################################################
### 2 Seite im Hauptcarousel mit testbutton zur datei Erstellung
### 2 Page in MainCarousel with testbutton for creating /exporting to a file
self.HauptCarousel2 = BoxLayout(orientation='vertical')
###############self.HauptCarousel.add_widget(self.HauptCarousel2)
self.HauptCarousel2.Texteingabe = TextInput(multiline=True)
self.HauptCarousel2.add_widget(self.HauptCarousel2.Texteingabe)
self.HauptCarousel2.ButtonSchreiben = Button(text="datei schreiben", on_release = self.datenpickeln)
self.HauptCarousel2.add_widget(self.HauptCarousel2.ButtonSchreiben)
#######################################################################
### 3 Seite im Hauptcarousel momentan mit Datei Auslesefunktion
### 3 Page in MainCarousel atm with functionality to read from file
self.HauptCarousel3 = BoxLayout(orientation='vertical')
######################self.HauptCarousel.add_widget(self.HauptCarousel3)
self.HauptCarousel3.Textausgabe = TextInput(multiline=True, readonly = True)
self.HauptCarousel3.add_widget(self.HauptCarousel3.Textausgabe)
self.HauptCarousel3.ButtonLesen = Button(text="datei auslesen", on_release = self.datenentpickeln)
self.HauptCarousel3.add_widget(self.HauptCarousel3.ButtonLesen)
#######################################################################
### 4 Seite im Hauptcarousel momentan mit Tischmanager
### 4 Page in Maincarousel atm with some kind of Table Manager
BackgroundcolorListe = [(1,0,0,1),(0,1,0,1),(0,0,1,1),(1,1,0,1)]
self.CustomLayout = CustomLayout()
self.HauptCarousel.add_widget(self.CustomLayout)
#self.CustomLayout.TopLabel = Label(text = 'Tisch[sup][color=#098125ff]Organizer[/sup][/b][/color]', markup = True,
#halign= 'left', valign= 'top', text_size= self.size, pos_hint={'x':0, 'y': 0}, font_size= '30sp')
self.CustomLayout.TopLabel = Label(text = 'Tisch[sup][color=#098125ff]Organizer[/sup][/b][/color]', markup = True,
halign= 'left', font_size= '30sp')
#self.CustomLayout.add_widget(self.CustomLayout.TopLabel)
self.CustomLayout.BoxLayout = BoxLayout (orientation = 'horizontal', size_hint = [1,0.05], pos_hint={'x':0, 'y': 0.95})
self.CustomLayout.add_widget(self.CustomLayout.BoxLayout)
self.CustomLayout.BoxLayout.add_widget(self.CustomLayout.TopLabel)
ButtonMenu1 = self.DropdownbuttonCreator()
self.CustomLayout.BoxLayout.Button1 = ButtonMenu1
## self.CustomLayout.BoxLayout.Button2 = Button(text = 'Tisch+' , on_release = self.tischhinzufuegen)
## self.CustomLayout.BoxLayout.Button3 = Button(text = 'Spalte+', on_release = self.spaltehinzufuegen)
## self.CustomLayout.BoxLayout.Button4 = Button(text = 'Zeile+', on_release = self.zeilehinzufuegen)
self.CustomLayout.BoxLayout.add_widget(self.CustomLayout.BoxLayout.Button1)
## self.CustomLayout.BoxLayout.add_widget(self.CustomLayout.BoxLayout.Button2)
## self.CustomLayout.BoxLayout.add_widget(self.CustomLayout.BoxLayout.Button3)
## self.CustomLayout.BoxLayout.add_widget(self.CustomLayout.BoxLayout.Button4)
self.CustomLayoutGridLayout = GridLayout(cols = 3, rows = 4, padding = [20,20], spacing = [30,30], size_hint = [1,0.95], pos_hint={'x':0, 'y': 0})
#cGridLayout = StackLayout(orientation = "tb-lr", padding = [20,20], spacing = [30,30], size_hint = [1,0.9], pos_hint={'x':0, 'y': 0})
self.CustomLayout.add_widget(self.CustomLayoutGridLayout)
self.Tischliste = []
Auswahlliste = ["Bestellung", "Abrechnung", "Best. Aendern", "Bennenen"]
AnzahlTische = 12
Zielwidget = self.CustomLayoutGridLayout
self.tischerstellung(Zielwidget,AnzahlTische, Auswahlliste, BackgroundcolorListe)
self.ProduktOrganizerInstanz = ProduktOrganizer()
self.HauptCarousel.add_widget(self.ProduktOrganizerInstanz)
ButtonHinzufuegen = self.ProduktOrganizerInstanz.ids.ProduktlisteButtonHinzufuegen
ButtonHinzufuegen.on_release = self.produkthinzufuegen
self.PopupInst = PopupBildAuswaehlenProduktorganizer()
popup = self.PopupInst.ids.a
self.ProduktOrganizerInstanz.ids.ProduktBildAuswaehlen.on_release = popup.open
self.CustomScrollviewProduktOrganizer = CustomScrollviewProduktOrganizer
self.CustomScrollviewProduktOrganizerInstanz = CustomScrollviewProduktOrganizer()
self.ProduktOrganizerItemInstanz = CustomScrollviewItem()
self.ProduktOrganizerInstanz.add_widget(Button(text= 'test', on_release = self.listeaktualisieren))
#self.ProduktOrganizerInstanz.ids.ProduktlisteButtonHinzufuegen.on_release = self.listeaktualisieren
self.ProduktOrganizerInstanz.add_widget(Button(text= 'manuell', on_release = self.itemmanuellhinzufuegen))
self.ProduktOrganizerInstanz.add_widget(Button(text= 'listeaktualisiern+pos', on_release = self.positionenzeigen))
def itemmanuellhinzufuegen(self,widget):
self.CustomScrollviewProduktOrganizerInstanz = CustomScrollviewProduktOrganizer()
#print dir(self.CustomScrollviewProduktOrganizerInstanz.ids.content2.children)
self.CustomScrollviewProduktOrganizerInstanz.ids.content2.clear_widgets()
self.testButtonx = Button(text='testbutton', size_hint = (1,1))
#self.CustomScrollviewProduktOrganizerInstanz.ids.content2.add_widget(self.testButtonx)
#print dir(self.CustomScrollviewProduktOrganizerInstanz.ids)
def positionenzeigen(self,widget):
#print self.testButtonx.pos
#print self.testButtonx.size
self.listeaktualisieren(self)
def listeaktualisieren(self, widget):
#print 'listeacktualisieren wurde ausgefuert'
#self.CustomScrollviewProduktOrganizer = CustomScrollviewProduktOrganizer()
#print [str(i) for i in range(30)]
#self.CustomScrollviewProduktOrganizerInstanz.data = ['0','1','2','3','4']
self.CustomScrollviewProduktOrganizerInstanz.data = [str(i) for i in App.HauptListeDictonaries]
#print dir(self.CustomScrollviewProduktOrganizer.children)#content2.clear_widgets()
def produkthinzufuegen(self):
NeuesDict ={}
WertEingabeFeldBezeichnung = self.ProduktOrganizerInstanz.ids.EingabeFeldBezeichnung.text
WertEingabeFeldPreis = self.ProduktOrganizerInstanz.ids.EingabeFeldPreis.text
## StatusCheckBoxVerkauf = self.ProduktOrganizerInstanz.ids.CheckBoxVerkauf.active
WertSpinnerKategorie = self.ProduktOrganizerInstanz.ids.SpinnerKategorie.text
filechooser = self.PopupInst.ids.filechooser
DateiAuswahl = (str(filechooser.selection))[((str(filechooser.selection)).find('/pictures')):-2]
#print 'hallo', WertEingabeFeldBezeichnung, WertEingabeFeldPreis,DateiAuswahl,WertSpinnerKategorie
NeuesDict = {'Bezeichnung':WertEingabeFeldBezeichnung,
'Preis':WertEingabeFeldPreis,
'Bild':DateiAuswahl,
'Kategorie':WertSpinnerKategorie}
#print 'len(App.HauptListeDictonaries)', (len(App.HauptListeDictonaries))
if len(App.HauptListeDictonaries)<1:
App.HauptListeDictonaries.append(NeuesDict)
print 'Fall 1'
else:
for i in range(len(App.HauptListeDictonaries[:])):
print 'App.HauptListeDictonaries[i][Bezeichnung] ist', App.HauptListeDictonaries[i]['Bezeichnung']
Bezeichnungdict = str(App.HauptListeDictonaries[i]['Bezeichnung'])
Bezeichnungneuesdict = str(NeuesDict['Bezeichnung'])
if Bezeichnungdict == Bezeichnungneuesdict:
Treffer = True
break
else:
Treffer = False
if Treffer == True:
#print 'Dieses Produkt existiert schon'
ButtonVerstanden = Button(text='Verstanden')
popup = Popup(title='Dieses Produkt existiert bereits ',
size_hint = (0.5, 0.25),
content= ButtonVerstanden)
popup.open()
ButtonVerstanden.on_release = popup.dismiss
else:
App.HauptListeDictonaries.append(NeuesDict)
print len(App.HauptListeDictonaries)
for index, item in enumerate(App.HauptListeDictonaries):
print index, item
def DropdownbuttonCreator(self):
Auswahlliste = ["Tisch +", "Tisch -", "Spalte + ", "Spalte -", "Reihe + ", "Reihe -"]
BackgroundcolorListe = [(0,1,0,1),(1,0,0,1),(0,1,0,1),(1,0,0,1),(0,1,0,1),(1,0,0,1)]
Aktionsliste = [self.tischhinzufuegen, self.tischentfernen, self.spaltehinzufuegen, self.spalteentfernen, self.zeilehinzufuegen, self.zeileentfernen]
DropdownObjekt = CustomDropDown()
DropdownObjektButton = CustomButton(text = "Menue",
#DropdownObjektButton = ToggleButton(text="Menue",
size_hint=[1,1],
background_color = (0.8, 0.8, 0.00, 1),
background_normal='bilder_oberflaeche/white2.png',
background_down='bilder_oberflaeche/white3.png')
#self.CustomLayout.add_widget(DropdownObjektButton)
DropdownObjektButton.bind(on_release=DropdownObjekt.open)
self.DropdownObjects.append(DropdownObjekt)
for x in range(len(Auswahlliste)):
DropdownUnterbutton = Button(text=Auswahlliste[x], font_size = 15, size_hint_y=None, height=60,
background_color = BackgroundcolorListe[x],
background_normal='bilder_oberflaeche/white2.png',
background_down='bilder_oberflaeche/white3.png',
opacity = 0.8,
on_release = Aktionsliste[x])
DropdownObjekt.add_widget(DropdownUnterbutton)
ButtonMenu1 = DropdownObjektButton
return ButtonMenu1
def tischerstellung (self, Zielwidget, AnzahlTische, Auswahlliste, BackgroundcolorListe):
Auswahlliste = ["Bestellung", "Abrechnung", "Best. Aendern", "Bennenen"]
BackgroundcolorListe = [(1,0,0,1),(0,1,0,1),(0,0,1,1),(1,1,0,1)]
Aktionsliste = [self.bestellung, self.abrechnung, self.bestellungaendern, self.tischbenennen]
#self.DropdownObjects = []
for i in range(AnzahlTische):
if self.Tischliste != []:
LetzterTisch = self.Tischliste[-1]['Nummer']
## print LetzterTisch + 1
else:
LetzterTisch = 0
TischNr = str(LetzterTisch+1)
TischButtonText = "T " + TischNr
DropdownObjekt = CustomDropDown() #von kovak hinzugefuegt
#DropdownObjektButton = CustomButton(text = TischButtonText,
DropdownObjektButton = ToggleButton(text = TischButtonText,
group='Tische',
background_normal='bilder_oberflaeche/white2.png',
background_down='bilder_oberflaeche/white4.png',
background_color = (0.79, 0.39, 0.09, 0.6))
Zielwidget.add_widget(DropdownObjektButton)
DropdownObjektButton.bind(on_release=DropdownObjekt.open)
self.DropdownObjects.append(DropdownObjekt) #von kovak hinzugefuegt
for x in range(len(Auswahlliste)):
DropdownUnterbutton = Button(text=Auswahlliste[x],
id = TischNr,
#auto_width='False',
#width = '200sp',
font_size = 15,
size_hint_y=None,
height=60,
background_normal='bilder_oberflaeche/white2.png',
background_down='bilder_oberflaeche/white3.png',
background_color = BackgroundcolorListe[x],
on_release = Aktionsliste[x])
DropdownObjekt.add_widget(DropdownUnterbutton)
#print' button', i, 'unterbutton', x
DropdownObjektButton.text= TischButtonText
self.TischButtondict = {'Nummer':(LetzterTisch + 1),'Objekt':DropdownObjektButton}
self.Tischliste.append(self.TischButtondict)
def garbagecollectortracking(self, widget):
for i in self.Tischliste:
a = i
print gc.is_tracked(a)
### function for Editing a Table#######################################
#def tischmanipulieren(self, widget):
# widget.text = 'mein text'
#### function for adding an extra table to layout ##########################
def tischhinzufuegen(self, widget):
if len(self.Tischliste) >= 1:
if hasattr(self, 'CustomLayoutBottomLabel'):
self.CustomLayout.remove_widget(self.CustomLayoutBottomLabel)
AnzahlTische = 1
Zielwidget = self.CustomLayoutGridLayout
Auswahlliste = ["Bestellung", "Abrechnung", "Best. Aendern", "Bennenen"]
BackgroundcolorListe = [(1,0,0,1),(0,1,0,1),(0,0,1,1),(1,1,0,1)]
LetzterTisch = self.Tischliste[-1]['Nummer']
if (self.CustomLayoutGridLayout.cols * self.CustomLayoutGridLayout.rows) <= (LetzterTisch +1):
self.CustomLayoutGridLayout.rows = self.CustomLayoutGridLayout.rows + 1
self.tischerstellung(Zielwidget, AnzahlTische, Auswahlliste, BackgroundcolorListe)
def tischentfernen(self, widget):
self.Warnlabel = 0
if len(self.Tischliste) <= 1:
if hasattr(self, 'CustomLayoutBottomLabel'):
# obj.attr_name exists.
if self.CustomLayoutBottomLabel in self.CustomLayout.children:
self.Warnlabel=1
print 'das ist der Letzte Tisch, der kann nicht entfernt werden'
if self.Warnlabel == 0:
self.CustomLayoutBottomLabel= Label(text='Das ist der Letzte Tisch,\n der kann nicht \n entfernt werden', text_size = self.size)
self.CustomLayout.add_widget(self.CustomLayoutBottomLabel)
else:
Zielwidget = self.CustomLayoutGridLayout
Zielwidget.remove_widget(self.Tischliste[-1]['Objekt'])
del self.Tischliste[-1]
LetzterTisch = self.Tischliste[-1]['Nummer']
print 'die anzahl der Tische ist nun:', LetzterTisch
pass
#### function for adding a column to layout ####################################
def spaltehinzufuegen(self, widget):
if self.CustomLayoutGridLayout.cols >= 1:
if hasattr(self, 'CustomLayoutBottomLabel'):
self.CustomLayout.remove_widget(self.CustomLayoutBottomLabel)
self.WarnLabel = 0
self.CustomLayoutGridLayout.cols = self.CustomLayoutGridLayout.cols + 1
print 'Zeile hinzufuegen'
def spalteentfernen(self, widget):
self.Warnlabel = 0
if self.CustomLayoutGridLayout.cols <= 1:
if hasattr(self, 'CustomLayoutBottomLabel'):
# obj.attr_name exists.
if self.CustomLayoutBottomLabel in self.CustomLayout.children:
self.Warnlabel=1
print 'das ist die letzte Tischreihe, sie kann nicht entfernt werden'
if self.Warnlabel == 0:
self.CustomLayoutBottomLabel= Label(text='Das ist die letzte Tischreihe,\n sie kann nicht \n entfernt werden', text_size = self.size)
self.CustomLayout.add_widget(self.CustomLayoutBottomLabel)
else:
TischanzahlVerbleibend = (self.CustomLayoutGridLayout.cols -1) * self.CustomLayoutGridLayout.rows
for i in range(len(self.Tischliste[TischanzahlVerbleibend:])):
self.CustomLayoutGridLayout.remove_widget(self.Tischliste[TischanzahlVerbleibend+ i]['Objekt'])
del self.Tischliste[TischanzahlVerbleibend:]
self.CustomLayoutGridLayout.cols = self.CustomLayoutGridLayout.cols - 1
#### function for adding a row to layout ####################################
def zeilehinzufuegen(self, widget):
if self.CustomLayoutGridLayout.rows >= 1:
if hasattr(self, 'CustomLayoutBottomLabel'):
self.CustomLayout.remove_widget(self.CustomLayoutBottomLabel)
self.WarnLabel = 0
self.CustomLayoutGridLayout.rows = self.CustomLayoutGridLayout.rows + 1
print 'Zeile hinzufuegen'
def zeileentfernen(self, widget):
self.Warnlabel = 0
if self.CustomLayoutGridLayout.rows <= 1:
if hasattr(self, 'CustomLayoutBottomLabel'):
# obj.attr_name exists.
if self.CustomLayoutBottomLabel in self.CustomLayout.children:
self.Warnlabel=1
print 'das ist die letzte Tischreihe, sie kann nicht entfernt werden'
if self.Warnlabel == 0:
self.CustomLayoutBottomLabel= Label(text='Das ist die letzte Tischreihe,\n sie kann nicht \n entfernt werden', text_size = self.size)
self.CustomLayout.add_widget(self.CustomLayoutBottomLabel)
else:
TischanzahlVerbleibend = (self.CustomLayoutGridLayout.rows -1) * self.CustomLayoutGridLayout.cols
for i in range(len(self.Tischliste[TischanzahlVerbleibend:])):
self.CustomLayoutGridLayout.remove_widget(self.Tischliste[TischanzahlVerbleibend+ i]['Objekt'])
del self.Tischliste[TischanzahlVerbleibend:]
self.CustomLayoutGridLayout.rows = self.CustomLayoutGridLayout.rows - 1
def bestellung(self, widget):
TischNr = widget.id
PopupFloatLayout = FloatLayout(size_hint=(1, 1))
self.PopupScrollview = CustomScrollviewPopupContent()
self.PopupScrollviewItem = CustomButton2()
self.PopupScrollview.data = [str(i) for i in range(10)]
#content = self.PopupScrollview.ids.content
#item = self.PopupScrollviewItem
popup = Popup(title='Bestellung für Tisch ' + str(TischNr),
content= PopupFloatLayout)
## for i in range(9):
## content.add_widget(CustomButton(text = str(i)))
#self.PopupScrollview.ids.CSPopup.open()
#print dir(CustomScrollviewPopupContent.data)
ButtonExit = Button(text="Exit",
pos_hint={'x': 0.825, 'y': 1.005},
size_hint = [0.2,0.065],
on_release = popup.dismiss)
PopupFloatLayout.add_widget(ButtonExit)
self.PopupScrollview.size_hint = [1.05,1.017]
self.PopupScrollview.center = popup.center
PopupFloatLayout.add_widget(self.PopupScrollview)
self.PopupScrollview.ids.populate.on_release = self.kasse
popup.open()
##
## def on_data(self, instance, value):
## content_add = self.PopupScrollview.ids.content.add_widget
## for item in value:
## print item
## content_add(CustomButton2(text=item))
#return CustomScrollviewPopupContent()
def kasse(self):
self.PopupScrollview.data = [str(i) for i in range(30)]
#print dir(CustomScrollviewPopupContent().ids.viewitems)
#y.ids.content.clear_widgets()
## x.data = ListProperty([str(i) for i in range(10)])
## print 'x.data', x.data
##
## print CustomScrollviewPopupContent.data
## CustomScrollviewPopupContent.data = x.data
## print '2ens', CustomScrollviewPopupContent.data
def groesse(self,widget):
print 'die buttongroesse ist:', widget.size
def abrechnung(self, widget):
TischNr = widget.id
PopupFloatLayout = FloatLayout()
self.ScreenmanagerPopup = CustomScreenManager()
self.ScreenPopup = CustomScreen
for x in xrange(4):
self.ScreenmanagerPopup.add_widget(self.ScreenPopup(name='Screen %d' % x))
#popup = Popup(title='Abrechnung für ' + str(TischNr),
# content=self.ScreenmanagerPopup,size_hint=(1, 1) )
popup = Popup(title='Abrechnung für Tisch' + str(TischNr),
content=PopupFloatLayout)#,
#size_hint=(1, 1),
#pos_hint={'x': 0.5, 'y': 0.5} )
self.ScreenmanagerPopup.pos_hint = {'x': 0, 'y': 0}
PopupFloatLayout.add_widget(self.ScreenmanagerPopup)
ButtonExit = Button(text="Exit",
pos_hint={'x': 0.8, 'y': 1.005},
size_hint = [0.2,0.065],
on_release = popup.dismiss)
PopupFloatLayout.add_widget(ButtonExit)
popup.open()
def bestellungaendern(self, widget):
pass
def tischbenennen(self, widget):
TischNr = widget.id
PopupBox1LayoutTischBennenen = BoxLayout(orientation = 'vertical')
popup = Popup(title='Tisch Nr. ' + str(TischNr) + 'benennen',
content=PopupBox1LayoutTischBennenen,
size_hint=(0.75, 0.5))
EingabeTextfeld = TextInput(text='hier Tischbezeichnung eintragen - Funktion muss noch eingebaut werden')
PopupBox1LayoutTischBennenen.add_widget(EingabeTextfeld)
PopupBoxLayoutTischBenennen = BoxLayout(orientation = 'horizontal', size_hint=(1,1))
ButtonAbbrechenTischBenennen = Button(text="Abbrechen", size_hint=(0.5, 0.5))
ButtonAbbrechenTischBenennen.bind(on_press=popup.dismiss)
ButtonOkTischBenennen = Button(text="OK", size_hint=(0.5, 0.5))
ButtonOkTischBenennen.bind(on_press=popup.dismiss)
PopupBox1LayoutTischBennenen.add_widget(PopupBoxLayoutTischBenennen)
PopupBoxLayoutTischBenennen.add_widget(ButtonAbbrechenTischBenennen)
PopupBoxLayoutTischBenennen.add_widget(ButtonOkTischBenennen)
#popup.add_widget
popup.open()
pass
#### function for exporting Data to file ####################################
def datenpickeln(self, widget):
BonListe = self.HauptCarousel2.Texteingabe.text
'''function to pickle data to make it ready for sending'''
try:
with open('bonliste.txt', 'w+b') as BonListeDaten_File:
pickle.dump(BonListe, BonListeDaten_File)
except IOError as err:
print('Dateifehler: ' + str(err))
except pickle.PickleError as perr:
print('Pickling Fehler: ' + str(perr))
#### function for importing Data to file ####################################
def datenentpickeln(self, widget):
with open('bonliste.txt', 'rb') as BonListeDaten_File_entpickelt:
BonListeWiederhergestellt = pickle.load(BonListeDaten_File_entpickelt)
print 'die entpickelte BinListe ist: '
print BonListeWiederhergestellt
BonListe = BonListeWiederhergestellt
self.HauptCarousel3.Textausgabe.text = BonListe
class CustomDropDown(DropDown):
def open(self, instance):
print 'opening dropdown', instance
super(CustomDropDown, self).open(instance)
class CustomButton(Button):
def on_release(self):
print 'button release'
super(CustomButton, self).on_release()
class CustomLayout(FloatLayout):
def __init__(self, **kwargs):
# make sure we aren't overriding any important functionality
super(CustomLayout, self).__init__(**kwargs)
with self.canvas.before:
Color(1,0,0,0.2) # green; colors range from 0-1 instead of 0-255
self.rect = Rectangle(
source='bilder_oberflaeche/tischmanagerboden1024_768.jpg',
size=self.size,
pos=self.pos)
self.bind(
size=self._update_rect,
pos=self._update_rect)
def _update_rect(self, instance, value):
self.rect.pos = instance.pos
self.rect.size = instance.size
class BonierungsprogrammApp(App):
App.my_index = 0
App.my_index2 = 0
App.Pfade = 0
App.Namensliste = ['Cola','Wasser','Bier','Wein']
#App.HauptListeDictonaries = ListProperty([])
App.HauptListeDictonaries = []
TestDict = {'Bezeichnung':'testitem','Preis':'testpreis','Bild':'testpildbfad','Kategorie':'Testkategorie'}
App.HauptListeDictonaries.append(TestDict)
## def __init__(self, **kwargs):
## pass
def build(self):
return LoginScreen()
if __name__ == '__main__':
BonierungsprogrammApp().run()