class StockPopup(AdminPopup): CardId = StringProperty('0') #used to add new RFID cards to DB def __init__(self, Parent, Theme, Title, Message, **kwargs): super(StockPopup, self).__init__(Parent, Title, Message, **kwargs) self.Parent = Parent self.Theme = Theme self.engine = DbEngine(self) self.okButton.text = 'fertig' self.cancelButton.disabled = True def getStock(self, *args): label = Label(text='[b]Ean[/b]', halign='left', markup=True, size_hint_x=None, width=120) label.text_size = (label.width, None) self.innerLayout.add_widget(label) label = Label(text='[b]Getränk[/b]', halign='left', markup=True, size_hint_x=None, width=220) label.text_size = (label.width, None) self.innerLayout.add_widget(label) label = Label(text='[b]Bestand[/b]', halign='left', markup=True) label.text_size = (label.width, None) self.innerLayout.add_widget(label) dbResult = self.engine.getProducts(100, 100, True) for Product in dbResult: label = Label(text=Product[0], halign='left', size_hint_x=None, width=120) label.text_size = (label.width, None) self.innerLayout.add_widget(label) label = Label(text=Product[1], halign='left', size_hint_x=None, width=220) label.text_size = (label.width, None) self.innerLayout.add_widget(label) label = Label(text='{:5d}'.format(Product[2]), halign='right') label.text_size = (.5 * label.width, None) self.innerLayout.add_widget(label) # event handlers def on_open(self, *args): #stop timeout of Admin screen self.Parent.timeOut.cancel() self.getStock() def on_dismiss(self, *args): #trigger timout on Adminscreen self.Parent.timeOut()
class Selection(GridLayout): # Widget containing the list of drinks UserGroup = 0 UserBalance = 0 def __init__(self, CardId, parent, **kwargs): super(Selection, self).__init__(**kwargs) self.spacing = 10 self.cols = 4 self.padding = (60, 10, 0, 0) self.size_hint_x = (.9) self.row_default_height = 40 self.row_force_default = True self.Buttons = [] self.engine = DbEngine(self) self.CardId = CardId self.UserGroup = 0 def get_product_list(self, Theme): #get Productlist based the user's group self.UserId, self.UserGroup, self.isCredit = self.engine.getUserInfo( self.CardId) if self.UserId: self.UserBalance = self.engine.getUserBalance(self.CardId) else: popup = Popup( title='Warnung', content=Label( text='Benutzer für RFID\n {} \nnicht gefunden'.format( self.CardId), size_hint_x=.9, halign='center'), size_hint=(None, None), size=(300, 200)) self.timeOut = Clock.schedule_once(self.no_input, 2) popup.open() Close_me = Clock.schedule_once(popup.dismiss, 3) if self.UserGroup: if self.isCredit: dbResult = self.engine.getProducts(self.UserGroup, 100) else: dbResult = self.engine.getProducts(self.UserGroup, self.UserBalance) #display results j = 0 for Product in dbResult: Productlist = self.Buttons.append( DrinkButton(Product[2], Product[1], self.UserId, Product[3], 'Themes/{}/Button1'.format(Theme))) self.add_widget(self.Buttons[j]) self.Buttons[j].bind(on_release=self.Buttons[j].callback) self.add_widget( Label( text='{:.2f}'.format(Product[3]) + ' €', bold=True, )) j = j + 1 if (j == 0): self.add_widget( InfoLine(text='Keine passenden Produkte gefunden')) def on_enter(self): self.timeOut = Clock.schedule_once(self.no_input, TIMEOUT) def on_leave(self): self.timeOut.cancel() def no_input(self, instance): self.parent.parent.no_input(self)