| 12
 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
 
 |  
class Application(Frame):
        def __init__(self,master):
 
                # Frame d'affichage du Ticket #
                FrameT = Frame(master,width=200,height=200)
                FrameT.pack()
                FrameT.propagate(False)
 
                Ticket(FrameT)
 
                # Frame d'affichage des produits #
                FrameP = Frame(master,width=200,height=200)
                FrameP.pack()
                FrameP.propagate(False)
 
                Produits(FrameP)
 
class Ticket(Frame):
        def __init__(self,master,*args):
 
                # Si aucun numéro de ticket n'a été définie, je récupère le numéro MAX contenue dans la Table Tickets, et j'incrémente de 1
                if args == (): 
                        nb = Mysqlrequests.NewTicket()  
                        numero = nb[0]
                        numero +=1
                else:
                        numero = args[0]
 
                self.LabelTicketN = Label(master,text="Ticket n° %s" % (numero))
                self.LabelTicketN.pack()
 
                ListProduits = Mysqlrequests.TicketProducts(numero) # Recup des produits du ticket
                for p in ListProduits:
                        Pname = p[0]
                        self.LProduit = Label(master,text=Pname)
                        self.LProduit.pack()
 
class Produits(Frame):
        def __init__(self,master):
                Produits = ["pizza","frite","coca"] # en vrais les produits sont dans la BDD, mais pour l'exemple j'ai préféré utilisé une liste
                for produit in Produits:
                        PButtons = Button(master,text=produit,fg='black',state='normal',command=lambda Pname=produit:self.ProduitAdd(Pname),width=20,height=3)
                        PButtons.pack()
 
        def ProduitAdd(self,Pname):
                Mysqlrequests.ProductAdd(self.numero,Pname) Ajout du produit au ticket
 
tk = Tk()
app = Application(tk)
tk.mainloop() | 
Partager