IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Tkinter Python Discussion :

Gestion d'un restaurant


Sujet :

Tkinter Python

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre averti
    Profil pro
    Inscrit en
    Décembre 2008
    Messages
    21
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2008
    Messages : 21
    Par défaut Gestion d'un restaurant
    Bonjours, Je suis etrangere, neglige des erreurs grammaire, stp
    Je suis debutante, je veux faire un truc pouvant etre mis a un PDA a restaurant qui sert a faire commandes par les clients et les serveurs, et il realise les fonctions basiques telles que Faire l’addition, Sélectionner des plats, Connaître le nombre de couverts, Repérer les tables réservées, Voir la ommande complète, Vérifier la disponibilité des plats, D’annuler, ou de modifier toute opération..
    Je rencontre un probleme: j'ai mis un graphe .gif pour presenter les plats, et les etiquette par un <message> avec la fonction <ButtonRelease>, pour apparaitre l'etiquette quand le curseur touche des plats, le probleme est qu'il ne distingue pas des differents plats et il apparait toujours la meme etiquette, du cours, il commande le meme plat n'importe quel plat on a choisi. Je veux ajouter un argument pour les distinguer, mais j'ai pas reussit. Le code concernee que j'ai ecrit est la suivante:
    Merci d'avance.


    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    from Tkinter import *
     
     
    mot=''
    mots=[]
    toumots=[]
    motinf=''
    no=0
     
     
    def curseur_main(e):
        global fenbul
        eti=StringVar()
        can1.config(cursor='hand2')
        fenbul=Toplevel()
        fenbul.config(bg='yellow')
        geo1=fen1.winfo_geometry()
        geox=fen1.winfo_rootx()
        geoy=fen1.winfo_rooty() 
        fenbul.geometry("50x19+"+str(geox+90)+"+"+str(geoy+80))
        fenbul.resizable(width=False, height=False)
        fenbul.overrideredirect(1)
        mes=Message(fenbul,bg='yellow',fg='black',width=500,font=('Arial', 8),text="GLACE",relief=RIDGE, aspect=001, textvariable="2.7")
        mes['text']=eti.get()
        mes.pack()
        mot= str(mes['aspect'])+'/'+mes['text']+'/'+mes['textvariable']
     
     
     
     
     
    def infos(e) :
     
        global feninf,prix
        prix=0
        prixto=0
        eti=StringVar()
        feninf = Toplevel()
        feninf.config(bg='lightblue')
        geo1=fen1.winfo_geometry()
        geox=fen1.winfo_rootx()
        geoy=fen1.winfo_rooty() 
        feninf.geometry("300x400+"+str(geox-20)+"+"+str(geoy-30))
        feninf.resizable(width=False, height=False)
        feninf.title("Les articles deja commandes")
        feninf.button=Button(feninf,text="ENVOYER", fg='blue',command=envoyer).pack(side=BOTTOM,pady=2)
        mesinf=Message(fenbul,bg='yellow',fg='black',width=500,font=('Arial', 8),text="GLACE",relief=RIDGE, aspect=001, textvariable="2.7")
        mesinf['text']=eti.get()
        mesinf.pack()
     
        motinf= str(mesinf['aspect'])+'/'+mesinf['text']+'/'+mesinf['textvariable']
        prix=mesinf['textvariable']
     
        scrolly =Scrollbar(feninf,orient=VERTICAL)
        memo=Listbox(feninf,yscrollcommand=scrolly.set)
        memo.pack(side=LEFT, fill=BOTH, expand=1)
     
        scrolly.config(command=memo.yview)
        scrolly.pack(side=LEFT,fill=Y)    
        memo.pack()
        mots.append(motinf)
        memo.insert(0,motinf)
        fic = open('liste.txt','w')  
        fic = open('liste.txt','a')
        fic.write("numclient:")
        fic.write(str(no))
        fic.write("\n")
        fic.write("numarticle/article/prix")
        fic.write("\n")
        fic.write(motinf)
        fic.write("\n")
        fic.close()
        print motinf
     
     
    def curseur_fleche(e) :
        restau_curseur()
     
    def restau_curseur() :
        global fenbul
        fen1.config(cursor='arrow')
        fenbul.destroy()
     
    def ordre():
        pass
     
    def entree():
        pass
     
    def quitter_prog() :
        global fenqui    
        fenqui=Toplevel()
        fenqui.config(bg='yellow',bd=3,relief='groove')
        geo1=fen1.winfo_geometry()
        geox=fen1.winfo_rootx()
        geoy=fen1.winfo_rooty() 
        fenqui.geometry("150x60+"+str(geox+220)+"+"+str(geoy+160))
        fenqui.resizable(width=False, height=False)
        fenqui.overrideredirect(1)
        labqui=Label(fenqui,bg='yellow',fg='red',font=('Arial', 10),text="Quitter Commande?")
        labqui.place(x=17,y=1)
        repon=StringVar()
        bououi=Button(fenqui,text="Oui", bg='pink', fg='black',command=confir_quitter)
        bounon=Button(fenqui,text="Non", bg='pink', fg='black',command=continu_prog)
        bououi.place(x=20,y=25)
        bounon.place(x=90,y=25)
        fenqui.grab_set()
     
    def confir_quitter() :
        fen1.destroy()
     
    def continu_prog() :
        global fenqui
        fenqui.destroy()
     
    def ordre():
        global ent,fenord
        fenord=Toplevel()
        geo1=fen1.winfo_geometry()
        geox=fen1.winfo_rootx()
        geoy=fen1.winfo_rooty() 
        fenord.geometry("217x30+"+str(geox-2)+"+"+str(geoy-85))
        Label(fenord, text="NUMERO: ").grid(row=0, sticky=W)
        ent = Entry(fenord)
        ent.grid(row=0, column=1)
        Button(fenord, text="OK", command = numeroter).grid(row = 0, column = 2)
     
    def numeroter():
        global no
        no=0
        no=int(ent.get())
        fenord.destroy()
        print no
     
    def envoyer():
        global fenenv
        fenenv=Toplevel()
        geo1=fen1.winfo_geometry()
        geox=fen1.winfo_rootx()
        geoy=fen1.winfo_rooty() 
        fenenv.geometry("230x55+"+str(geox+13)+"+"+str(geoy+130))
        labenv=Label(fenenv,bg='yellow',fg='blue',width=30,font=('Arial', 10),text="Les commendes sont envoyees.")
        labenv.place(x=1,y=1)
        bouenv=Button(fenenv,text="OK", fg='blue',command=reussir).pack(side=BOTTOM,pady=3)
     
    def reussir() :
     
        fenenv.destroy()
        feninf.destroy()
     
     
     
    fen1 = Tk(className='Resto')
    fen1.resizable(width=False,height=False)
    fen1.geometry("480x320+300+200")
     
    fram1=Frame(fen1,bg='grey',bd=2,relief='ridge')
    tit0=Label(fen1, text='Resto',fg='gold',bg='blue',font=('Arial', 20))
    tit0.place(x=10,y=10)
     
    can1 = Canvas(fram1, width=40, height=40)
    signat1=PhotoImage(file='glace.gif')
    sign1=can1.create_image(20,30, image=signat1,tag="glace")
    can1.tag_bind("glace","<Enter>",curseur_main)
    can1.tag_bind("glace","<ButtonRelease>",infos)
    can1.tag_bind("glace","<Leave>",curseur_fleche)
    can1.place(x=100,y=100)
     
    can2 = Canvas(fram1, width=40, height=40)
    signat2=PhotoImage(file='cafe.gif')
    sign2=can2.create_image(20,20, image=signat2,tag="cafe")
    can2.tag_bind("cafe","<Enter>",curseur_main)
    can2.tag_bind("cafe","<ButtonRelease>",infos)
    can2.tag_bind("cafe","<Leave>",curseur_fleche)
    can2.place(x=200,y=100)
     
    n=Button(fram1, text='NUMERO', command=ordre, bg='lightblue', fg='blue')
    n.place(x=10,y=50)
    fermer=Button(fram1, text="VALIDER", command=quitter_prog,bg='orange', fg='brown').pack(side=BOTTOM,pady=10)
     
    fram1.pack(side=LEFT,fill=BOTH,expand=1)
     
     
     
    fen1.mainloop()

  2. #2
    Membre averti
    Profil pro
    Inscrit en
    Décembre 2008
    Messages
    21
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2008
    Messages : 21
    Par défaut
    J'ecris separement les fonctions concernees can1 et can2 ("glace" et "cafe"), mais il faut repeter tous, comment le simplifier?

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
     
     
    from Tkinter import *
     
    mot=''
    mots=[]
    toumots=[]
    motinf=''
    no=0
     
    def curseur_main_can1(e):
        global fenbul
        eti=StringVar()
        can1.config(cursor='hand2') 
        fenbul=Toplevel()
        fenbul.config(bg='yellow')
        geo1=fen1.winfo_geometry()
        geox=fen1.winfo_rootx()
        geoy=fen1.winfo_rooty() 
        fenbul.geometry("50x19+"+str(geox+90)+"+"+str(geoy+80))
        fenbul.resizable(width=False, height=False)
        fenbul.overrideredirect(1)
        mes=Message(fenbul,bg='yellow',fg='black',width=500,font=('Arial', 8),text="GLACE",relief=RIDGE, aspect=001, textvariable="2.7")
        mes['text']=eti.get()
        mes.pack()
    ##    labbul=Label(fenbul,bg='yellow', fg='black',width=15,font=('Arial', 8),text="GLACE",relief=RIDGE)
    ##    labbul.pack()
        mot= str(mes['aspect'])+'/'+mes['text']+'/'+mes['textvariable']
     
     
    def curseur_main_can2(e):    
        global fenbul
        eti=StringVar()
        can1.config(cursor='hand2')  
        fenbul=Toplevel()
        fenbul.config(bg='yellow')
        geo1=fen1.winfo_geometry()
        geox=fen1.winfo_rootx()
        geoy=fen1.winfo_rooty() 
        fenbul.geometry("50x19+"+str(geox+90)+"+"+str(geoy+80))
        fenbul.resizable(width=False, height=False)
        fenbul.overrideredirect(1)
        mes=Message(fenbul,bg='yellow',fg='black',width=500,font=('Arial', 8),text="CAFE",relief=RIDGE, aspect=001, textvariable="1.2")
        mes['text']=eti.get()
        mes.pack()
    ##    labbul=Label(fenbul,bg='yellow', fg='black',width=15,font=('Arial', 8),text="GLACE",relief=RIDGE)
    ##    labbul.pack()
        mot= str(mes['aspect'])+'/'+mes['text']+'/'+mes['textvariable']
     
    def infos_can1(e) :    
        global feninf,prix
        prix=0
        prixto=0
        eti=StringVar()
        feninf = Toplevel()
        feninf.config(bg='lightblue')
        geo1=fen1.winfo_geometry()
        geox=fen1.winfo_rootx()
        geoy=fen1.winfo_rooty() 
        feninf.geometry("300x400+"+str(geox-20)+"+"+str(geoy-30))
        feninf.resizable(width=False, height=False)
        feninf.title("Les articles deja commandes")
        feninf.button=Button(feninf,text="ENVOYER", fg='blue',command=envoyer).pack(side=BOTTOM,pady=2)
        mesinf=Message(fenbul,bg='yellow',fg='black',width=500,font=('Arial', 8),text="GLACE",relief=RIDGE, aspect=001, textvariable="2.7")
        mesinf['text']=eti.get()
        mesinf.pack()
    ##    labbul=Label(fenbul,bg='yellow', fg='black',width=15,font=('Arial', 8),text="GLACE",relief=RIDGE)
    ##    labbul.pack()
        motinf= str(mesinf['aspect'])+'/'+mesinf['text']+'/'+mesinf['textvariable']
        prix=mesinf['textvariable']
     
        scrolly =Scrollbar(feninf,orient=VERTICAL)
        memo=Listbox(feninf,yscrollcommand=scrolly.set)
        memo.pack(side=LEFT, fill=BOTH, expand=1)
     
        scrolly.config(command=memo.yview)
        scrolly.pack(side=LEFT,fill=Y)    
        memo.pack()
        mots.append(motinf)
        memo.insert(0,motinf)
        fic = open('liste.txt','w')  
        fic = open('liste.txt','a')
        fic.write("numclient:")
        fic.write(str(no))
        fic.write("\n")
        fic.write("numarticle/article/prix")
        fic.write("\n")
        fic.write(motinf)
        fic.write("\n")
        fic.close()
        print motinf
     
    def infos_can2(e) :    
        global feninf,prix
        prix=0
        prixto=0
        eti=StringVar()
        feninf = Toplevel()
        feninf.config(bg='lightblue')
        geo1=fen1.winfo_geometry()
        geox=fen1.winfo_rootx()
        geoy=fen1.winfo_rooty() 
        feninf.geometry("300x400+"+str(geox-20)+"+"+str(geoy-30))
        feninf.resizable(width=False, height=False)
        feninf.title("Les articles deja commandes")
        feninf.button=Button(feninf,text="ENVOYER", fg='blue',command=envoyer).pack(side=BOTTOM,pady=2)
        mesinf=Message(fenbul,bg='yellow',fg='black',width=500,font=('Arial', 8),text="CAFE",relief=RIDGE, aspect=001, textvariable="1.2")
        mesinf['text']=eti.get()
        mesinf.pack()
    ##    labbul=Label(fenbul,bg='yellow', fg='black',width=15,font=('Arial', 8),text="GLACE",relief=RIDGE)
    ##    labbul.pack()
        motinf= str(mesinf['aspect'])+'/'+mesinf['text']+'/'+mesinf['textvariable']
        prix=mesinf['textvariable']
     
        scrolly =Scrollbar(feninf,orient=VERTICAL)
        memo=Listbox(feninf,yscrollcommand=scrolly.set)
        memo.pack(side=LEFT, fill=BOTH, expand=1)
     
        scrolly.config(command=memo.yview)
        scrolly.pack(side=LEFT,fill=Y)    
        memo.pack()
        mots.append(motinf)
        memo.insert(0,motinf)
        fic = open('liste.txt','w')  
        fic = open('liste.txt','a')
        fic.write("numclient:")
        fic.write(str(no))
        fic.write("\n")
        fic.write("numarticle/article/prix")
        fic.write("\n")
        fic.write(motinf)
        fic.write("\n")
        fic.close()
        print motinf
     
     
    def curseur_fleche_can1(e) :
        restau_curseur()
     
    def curseur_fleche_can2(e) :
        restau_curseur()
     
    def restau_curseur() :
        global fenbul
        fen1.config(cursor='arrow')
        fenbul.destroy()
     
     
    def ordre():
        pass
     
    def entree():
        pass
     
    def quitter_prog() :
        global fenqui    
        fenqui=Toplevel()
        fenqui.config(bg='yellow',bd=3,relief='groove')
        geo1=fen1.winfo_geometry()
        geox=fen1.winfo_rootx()
        geoy=fen1.winfo_rooty() 
        fenqui.geometry("150x60+"+str(geox+220)+"+"+str(geoy+160))
        fenqui.resizable(width=False, height=False)
        fenqui.overrideredirect(1)
        labqui=Label(fenqui,bg='yellow',fg='red',font=('Arial', 10),text="Quitter Commande?")
        labqui.place(x=17,y=1)
        repon=StringVar()
        bououi=Button(fenqui,text="Oui", bg='pink', fg='black',command=confir_quitter)
        bounon=Button(fenqui,text="Non", bg='pink', fg='black',command=continu_prog)
        bououi.place(x=20,y=25)
        bounon.place(x=90,y=25)
        fenqui.grab_set()
     
    def confir_quitter() :
        fen1.destroy()
     
    def continu_prog() :
        global fenqui
        fenqui.destroy()
     
    def ordre():
        global ent,fenord
        fenord=Toplevel()
        geo1=fen1.winfo_geometry()
        geox=fen1.winfo_rootx()
        geoy=fen1.winfo_rooty() 
        fenord.geometry("217x30+"+str(geox-2)+"+"+str(geoy-85))
        Label(fenord, text="NUMERO: ").grid(row=0, sticky=W)
        ent = Entry(fenord)
        ent.grid(row=0, column=1)
        Button(fenord, text="OK", command = numeroter).grid(row = 0, column = 2)
     
    def numeroter():
        global no
        no=0
        no=int(ent.get())
        fenord.destroy()
        print no
     
    def envoyer():
        global fenenv
        fenenv=Toplevel()
        geo1=fen1.winfo_geometry()
        geox=fen1.winfo_rootx()
        geoy=fen1.winfo_rooty() 
        fenenv.geometry("230x55+"+str(geox+13)+"+"+str(geoy+130))
        labenv=Label(fenenv,bg='yellow',fg='blue',width=30,font=('Arial', 10),text="Les commendes sont envoyees.")
        labenv.place(x=1,y=1)
        bouenv=Button(fenenv,text="OK", fg='blue',command=reussir).pack(side=BOTTOM,pady=3)
     
    def reussir() :
     
        fenenv.destroy()
        feninf.destroy()
     
     
     
    fen1 = Tk(className='Resto')
    fen1.resizable(width=False,height=False)
    fen1.geometry("480x320+300+200")
     
    fram1=Frame(fen1,bg='grey',bd=2,relief='ridge')
    tit0=Label(fen1, text='Resto',fg='gold',bg='blue',font=('Arial', 20))
    tit0.place(x=10,y=10)
     
    can1 = Canvas(fram1, width=40, height=40)
    signat1=PhotoImage(file='glace.gif')
    sign1=can1.create_image(20,30, image=signat1,tag="glace")
    can1.tag_bind("glace","<Enter>",curseur_main_can1)
    can1.tag_bind("glace","<ButtonRelease>",infos_can1)
    can1.tag_bind("glace","<Leave>",curseur_fleche_can1)
    can1.place(x=100,y=100)
     
     
    can2 = Canvas(fram1, width=40, height=40)
    signat2=PhotoImage(file='cafe.gif')
    sign2=can2.create_image(20,20, image=signat2,tag="cafe")
    can2.tag_bind("cafe","<Enter>",curseur_main_can2)
    can2.tag_bind("cafe","<ButtonRelease>",infos_can2)
    can2.tag_bind("cafe","<Leave>",curseur_fleche_can2)
    can2.place(x=200,y=100)
     
    n=Button(fram1, text='NUMERO', command=ordre, bg='lightblue', fg='blue')
    n.place(x=10,y=50)
    fermer=Button(fram1, text="VALIDER", command=quitter_prog,bg='orange', fg='brown').pack(side=BOTTOM,pady=10)
    fram1.pack(side=LEFT,fill=BOTH,expand=1)
     
     
    fen1.mainloop()

  3. #3
    Membre averti
    Profil pro
    Inscrit en
    Décembre 2008
    Messages
    21
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2008
    Messages : 21
    Par défaut
    un autre probleme, en considerant la pratique d'operations a un PDA, on evite de superposer et alterner les fenetres, j'envisage de mettre le Listbox a cote ou au-dessous de la fenetre posee les plats dedans, mais comment separer la fenetre a une partie plus petite pour le Listbox et l'autre partie plus grande? et comment controler le Listbox occuper un cote? Merci.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    fen1 = Tk(className='Resto')
    fen1.resizable(width=False,height=False)
    fen1.geometry("400x600+300+200")
     
    fram1=Frame(fen1,bg='grey',bd=2,relief='ridge',width=300, height=400)
    fram1.pack(fill=BOTH,expand=1)
    fram2=Frame(fen1,bg='grey',bd=2,relief='ridge',width=300, height=400)
    fram2.pack(fill=BOTH,expand=1)
     
    memo=Listbox(fram2)
    memo.grid(padx = 10, pady = 10)

  4. #4
    Membre émérite

    Profil pro
    Inscrit en
    Août 2004
    Messages
    723
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2004
    Messages : 723
    Par défaut
    Pour ce qui est de la gestion des plats, je te conseille de créer une classe Plat, qui contiendra toutes les données nécessaires et qui disposera d'une métode pour commander le plat en question. Après, quand tu lieras l'action de commande au clic sur l'image, il te suffira de donner la méthode "commande" du plat en question. Un exemple simple (que je te laisse le soin d'adapter à tes besoins.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    class Plat:
        def __init__(self, nom, img):
            self.nom = nom
            self.img = img
     
        def commander(self):
            #On crée la fenêtre de commande du plat
     
    #Au moment d'afficher l'image
    glace = Plat('Glace', 'glace.gif')
    can1 = Canvas(fram1, width=40, height=40)
    signat1=PhotoImage(file=glace.img)
    sign1=can1.create_image(20,30, image=signat1,tag=glace.nom)
    can1.tag_bind("glace","<Enter>",curseur_main_can1)
    can1.tag_bind("glace","<ButtonRelease>",glace.commander)
    can1.tag_bind("glace","<Leave>",curseur_fleche_can1)
    can1.place(x=100,y=100)
    Je te conseille grandement d'automatiser tout ça en utilisant une liste de plats, ça te permettra aussi de voir ce qui dépend de chaque plat, et ce qui n'en dépend pas (le changement de curseur par exemple). Comme ça, tu n'auras pas besoin de réécrire le même code à chaque fois. Je te conseille aussi, plus généralement, d'utiliser des classes qui gèrent tes différentes fenêtres, ça t'aidera au niveau lisibilité.

  5. #5
    Membre averti
    Profil pro
    Inscrit en
    Décembre 2008
    Messages
    21
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2008
    Messages : 21
    Par défaut
    Merci beaucoup, oiffrig~
    Je voudrais bien automatiser la gestion de plats, un probleme, je n'ai pas defini "self" (ni "class"), j'essaie de transformer les codes en ajoutant

    class resto(Tk):
    def __init__(self):
    Tk.__init__(self)
    ...
    mais il faut modifier toutes les fonctions et variables, cependant, je n'ai pas reussi. Encore, je ne sais pas comment mettre en place votre example a mon cas sans definir "self".

  6. #6
    Membre émérite

    Profil pro
    Inscrit en
    Août 2004
    Messages
    723
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2004
    Messages : 723
    Par défaut
    Le premier paramètre "self" de toute méthode de classe est une référence vers l'instance de la classe. Tu peux l'appeler autrement si tu veux, mais c'est le nom utilisé en général.

    Par exemple, si tu as une instance inst d'une classe, pour accéder à l'attribut attr tu utiliseras inst.attr en dehors de la classe, et self.attr dans une méthode (à condition d'avoir nommé self le premier paramètre).

    Pour plus de renseignements sur les classes, je te conseille les chapitres 11, 12 et 13 du tuto de Swinnen.

    C'est sûr que ça représente du travail de tout adapter, mais à mon avis ça te facilitera grandement la tâche.

Discussions similaires

  1. Création d'un système de gestion pour la restauration collective.
    Par Cuisinier66 dans le forum Macros et VBA Excel
    Réponses: 1
    Dernier message: 01/07/2014, 15h25
  2. Gestion d'un restaurant sur access
    Par salkaa dans le forum Access
    Réponses: 1
    Dernier message: 27/03/2013, 10h53
  3. [Open Source][PHP & MySQL] Gestion d'un restaurant avec Copix
    Par Laurentq1970 dans le forum Mon programme
    Réponses: 0
    Dernier message: 31/08/2009, 23h30
  4. Réponses: 3
    Dernier message: 24/03/2009, 14h14
  5. Gestion des partitions cachees et de restauration
    Par Aramis dans le forum Windows XP
    Réponses: 3
    Dernier message: 04/08/2008, 14h18

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo