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 :

Problème incompréhensible suite à un bug [Python 3.X]


Sujet :

Tkinter Python

  1. #1
    Membre à l'essai
    Homme Profil pro
    Étudiant
    Inscrit en
    Février 2015
    Messages
    27
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Vaucluse (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Février 2015
    Messages : 27
    Points : 23
    Points
    23
    Par défaut Problème incompréhensible suite à un bug
    Bonjour,

    je tente de faire un programme me permettant de lister mes animes / mangas vu / lu. Mais, suite à un bug, je ne m'y retrouve plus et les bugs s'accumulent .

    Pouvez vous m'aider ?

    Je vous donne le fichier. MangaList.py

  2. #2
    Membre à l'essai
    Homme Profil pro
    Étudiant
    Inscrit en
    Février 2015
    Messages
    27
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Vaucluse (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Février 2015
    Messages : 27
    Points : 23
    Points
    23
    Par défaut
    Bonjour,

    J'ai réussi à ranger le programme un minimum. Cependant, quand je choisis un manga dans la liste. Je peux le modifier via le bouton modifier mais si je fait retour puis que je choisis un manga le bouton modifier ne marche plus :/

    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
    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
    from tkinter import *
    from tkinter import tix
    from tkinter.constants import *
    from tkinter.messagebox import *
    import os, glob
     
    def Modifie() :
        global ESynopsis,EEpisode,ENote,EEtat,EAvis,varcombo,Modif
        try :
            fichier=open(varcombo.get()+".txt","w")
            fichier.write(ESynopsis.get()+"\n"+EEpisode.get()+"\n"+ENote.get()+"\n"+EEtat.get()+"\n"+EAvis.get())
            fichier.close()
            showinfo('MangaList','Modification effectué\nMerci !')
        except:
            showwarning('MangaList','Modification raté !\n Désolé !')
        Modif.destroy()
        Continuer()    
     
    def RetourMo() :
        global Modif
        Modif.destroy()
        Continuer()
     
    def Modif() :
        global varcombo, Manga, Modif, ESynopsis,EEpisode,ENote,EEtat,EAvis
        Manga.destroy()
     
        Modif=Tk()
        Modif.title("MangaList")
        Modif.geometry("350x360")
     
        fichier = open(varcombo.get()+".txt","r")
        info = fichier.read()
        ListeInfo = info.split("\n")
        fichier.close()
     
        Synopsis = ListeInfo[0]
        Episode = ListeInfo[1]
        Note = ListeInfo[2]
        Etat = ListeInfo[3]
        Avis = ListeInfo[4]
     
        if len(Synopsis)>=35 :
            Synopsis = Synopsis[:35]+"\n"+Synopsis[35:]
     
        if len(Avis)>=35 :
            Avis = Avis[:35] +"\n"+Avis[35:]
     
        LTitre = Label(Modif,text="MangaList",font=("Comic Sans MS",18,"bold"))
        LNom = Label(Modif,text="Nom : "+varcombo.get(),font=("Comic Sans MS",12))
        LSynopsis=Label(Modif,text="Résumé : ",font=("Comic Sans MS",12))
        LEpisode = Label(Modif,text="Ep : ",font=("Comic Sans MS",12))
        LNote = Label(Modif,text="Note : ",font=("Comic Sans MS",12))
        LEtat = Label(Modif,text="Etat : ",font=("Comic Sans MS",12))
        LAvis = Label(Modif,text="Avis : ", font=("Comic Sans MS",12))
        ESynopsis = Entry(Modif,width=30)
        EEpisode = Entry(Modif,width=10)
        ENote = Entry(Modif,width=10)
        EEtat = Entry(Modif,width=10)
        EAvis = Entry(Modif,width=30)
        ESynopsis.insert(END,Synopsis)
        EEpisode.insert(END,Episode)
        ENote.insert(END,Note)
        EEtat.insert(END,Etat)
        EAvis.insert(END,Avis)
     
        LTitre.place(x=100,y=30)
        LNom.place(x=20,y=80)
        LSynopsis.place(x=20,y=130)
        LEpisode.place(x=220,y=80)
        LNote.place(x=20,y=200)
        LEtat.place(x=220,y=200)
        LAvis.place(x=20,y=250)
        ESynopsis.place(x=110,y=140)
        EEpisode.place(x=280,y=90)
        ENote.place(x=90,y=210)
        EEtat.place(x=280,y=210)
        EAvis.place(x=100,y=260)
     
        BModifier=Button(Modif,text="Entrer",width=10,command=Modifie)
        BRetour=Button(Modif,text="Retour",width=10,command=RetourMo)
     
        BModifier.place(x=70,y=320)
        BRetour.place(x=200,y=320)
     
        Modif.mainloop()
     
    def RetourM() :
        global Manga
        Manga.destroy()
        Continuer()
     
    def Choix(e) :
        global varcombo, root, Manga
     
        root.destroy()
     
        try :
            Manga = Tk()
            Manga.title("MangaList")
            Manga.geometry("350x360")
     
     
            fichier = open(varcombo.get()+".txt","r")
            info = fichier.read()
            ListeInfo = info.split("\n")
            fichier.close()
     
            Synopsis = "Résumé : "+ListeInfo[0]
            Episode = "Ep : "+ListeInfo[1]
            Note = "Note : "+ListeInfo[2]
            Etat = "Etat : "+ListeInfo[3]
            Avis = "Avis : "+ListeInfo[4]
     
            LTitre = Label(Manga,text="MangaList",font=("Comic Sans MS",18,"bold"))
            LNom = Label(Manga,text="Nom : "+varcombo.get(),font=("Comic Sans MS",12))
     
            if len(Synopsis)>=35 :
                Synopsis = Synopsis[:35]+"\n"+Synopsis[35:]
     
            if len(Avis)>=35 :
                Avis = Avis[:35] +"\n"+Avis[35:]
     
            LSynopsis=Label(Manga,text=Synopsis,font=("Comic Sans MS",12))
            LEpisode = Label(Manga,text=Episode,font=("Comic Sans MS",12))
            LNote = Label(Manga,text=Note,font=("Comic Sans MS",12))
            LEtat = Label(Manga,text=Etat,font=("Comic Sans MS",12))
            LAvis = Label(Manga,text=Avis, font=("Comic Sans MS",12))
     
            BModifier=Button(Manga,text="Modifier",width=10,command=Modif)
            BRetour=Button(Manga,text="Retour",width=10,command=RetourM)
     
            LTitre.place(x=100,y=30)
            LNom.place(x=20,y=80)
            LSynopsis.place(x=20,y=130)
            LEpisode.place(x=220,y=80)
            LNote.place(x=20,y=200)
            LEtat.place(x=220,y=200)
            LAvis.place(x=20,y=250)
     
            BModifier.place(x=70,y=320)
            BRetour.place(x=200,y=320)
     
            Manga.mainloop()
        except :
            print("")
     
    def Ajou() :
        global EAjout, manga, Ajout, root
     
        Ajout = Tk()
        Ajout.title("MangaList")
        Ajout.geometry("300x200")
     
        LTitre = Label(Ajout,text="MangaList",font=("Comic Sans MS",18,"bold"))
        BRetour = Button(Ajout,text="Retour",width=10,command=RetourA)
     
        if EAjout.get() == "Manga a ajouter" or EAjout.get() in manga:
            LAvertissement = Label(Ajout,text="Veuillez remplir un \nnom du manga correct.", font=("Comic Sans MS",14,"bold"))
     
        else :
            try :
                fichier = open(EAjout.get()+".txt","w")
                fichier.write("Synopsis\n0/??\n0\nEC\nNone")
                fichier.close()
                LAvertissement = Label(Ajout,text="L'anime a été\ncréer sans problème.",font=("Comic Sans MS",14,"bold"))
            except :
                LAvertissement = Label(Ajout,text="L'anime n'a pas été\ncréer. Désolé.",font=("Comic Sans MS",14,"bold"))
     
        LTitre.place(x=80,y=30)
        LAvertissement.place(x=50,y=90)
        BRetour.place(x=100,y=150)
     
        root.destroy()
     
        Ajout.mainloop()
     
    def RetourS() :
        global Supprimer
     
        Supprimer.destroy()
        Continuer()
     
    def RetourA() :
        global Ajout
     
        Ajout.destroy()
        Continuer()
     
    def Supprime() :
        global ESupprimer, manga, root, Supprimer
     
        Supprimer = Tk()
        Supprimer.title("MangaList")
        Supprimer.geometry("300x200")
     
        LTitre = Label(Supprimer,text="MangaList",font=("Comic Sans MS",18,"bold"))
        BRetour = Button(Supprimer,text="Retour",width=10,command=RetourS)
     
        if ESupprimer.get()== "Manga a supprimer" or not ESupprimer.get()+".txt" in manga:
            LAvertissement = Label(Supprimer,text="Veuillez remplir un \nnom du manga correct.", font=("Comic Sans MS",14,"bold"))
     
        else :
            try :
                os.remove(ESupprimer.get()+".txt")
                LAvertissement = Label(Supprimer,text="L'anime a été\nsupprimer sans problème.",font=("Comic Sans MS",14,"bold"))
            except :
                LAvertissement = Label(Supprimer,text="L'anime n'a pas été\nsupprimer. Désolé.",font=("Comic Sans MS",14,"bold"))
     
        BRetour.place(x=100,y=150)
        LTitre.place(x=80,y=30)
        LAvertissement.place(x=50,y=90)
     
        root.destroy()
     
        Supprimer.mainloop()
     
    def RetourR():
        global root
        root.destroy()
        Me()
     
    def Continuer() :
        global EAjout, ESupprimer, manga, root, varcombo
        root = tix.Tk()
        root.title("MangaList")
        root.geometry("290x350")
     
        LTitre = Label(root,text="MangaList",font=("Comic Sans MS",18,"bold"))
        LChoix = Label(root,text="Choisissez un manga :",font=("Comic Sans MS",12,"bold"))
        EAjout = Entry(root)
        EAjout.insert(END,'Manga a ajouter')
        BAjout = Button(root,text="Ajouter un manga",width = 16,command=Ajou)
        ESupprimer = Entry(root)
        ESupprimer.insert(END,'Manga a supprimer')
        BSupprimer = Button(root,text="Supprimer un manga",width = 16, command = Supprime)
        BRetour = Button(root,text="Retour",width=16,command = RetourR)
     
        varcombo = tix.StringVar() 
        combo = tix.ComboBox(root, editable=1, dropdown=1, variable=varcombo, command = Choix)
        combo.entry.config(state='readonly')
     
        manga=glob.glob("*.txt")
     
        for i in range(0,len(manga)) :
            Liste=manga[i].split(".")
            combo.insert(i,Liste[0]) 
     
        EAjout.place(x=70,y=155)
        BAjout.place(x=70,y=180)
        ESupprimer.place(x=70,y=225)
        BSupprimer.place(x=70,y=250)
        BRetour.place(x=70,y=295)
        LTitre.place(x=70,y=20)
        LChoix.place(x=50,y=70)
        combo.place(x=60,y=110)
     
        root.mainloop()
     
    def Continueer() :
        Menu.destroy()
        if not os.path.isdir('Fichier') :
            os.mkdir('Fichier')
        os.chdir('Fichier')
        Continuer()
     
    def Quitter() :
        global Menu
        Menu.destroy()
     
    def Me():
        global Menu
     
        Menu = Tk()
        Menu.title("MangaList")
        Menu.geometry("240x170")
     
        LTitre = Label(Menu,text="MangaList",font=("Comic Sans MS",18,"bold"))
        BContinuer = Button(Menu,text="Continuer",width = 10,command=Continueer)
        BQuitter = Button(Menu,text="Quitter",width=10,command=Quitter)
     
        LTitre.place(x=60,y=20)
        BContinuer.place(x=80,y=80)
        BQuitter.place(x=80,y=120)
     
        Menu.mainloop()
     
    Me()

  3. #3
    Expert éminent

    Homme Profil pro
    Inscrit en
    Octobre 2008
    Messages
    4 300
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations forums :
    Inscription : Octobre 2008
    Messages : 4 300
    Points : 6 780
    Points
    6 780
    Par défaut
    Salut,

    Sans tester ton code, pas de mangas, je vois ceci qui n'est pas normal:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
     
    def RetourMo() :
        global Modif
        Modif.destroy()
        Continuer()
     
    def Modif() :
        global varcombo, Manga, Modif, ESynopsis,EEpisode,ENote,EEtat,EAvis
        Manga.destroy()
     
        Modif=Tk()
        ...
    Modif est une fonction existant dans l'espace global du code et tu réutilises le même nom pour ta fenêtre, que tu te permet ensuite de détruire dans la fonction RetourMo. Tout ce qu'il faut pour que ça foire.

  4. #4
    Membre à l'essai
    Homme Profil pro
    Étudiant
    Inscrit en
    Février 2015
    Messages
    27
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Vaucluse (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Février 2015
    Messages : 27
    Points : 23
    Points
    23
    Par défaut
    C'est pas faux

    Bref, j'ai donc fait cela :
    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
    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
    from tkinter import *
    from tkinter import tix
    from tkinter.constants import *
    from tkinter.messagebox import *
    import os, glob
     
    def Modifie() :
        global ESynopsis,EEpisode,ENote,EEtat,EAvis,varcombo,Modifi
        try :
            fichier=open(varcombo.get()+".txt","w")
            fichier.write(ESynopsis.get()+"\n"+EEpisode.get()+"\n"+ENote.get()+"\n"+EEtat.get()+"\n"+EAvis.get())
            fichier.close()
            showinfo('MangaList','Modification effectué\nMerci !')
        except:
            showwarning('MangaList','Modification raté !\n Désolé !')
        Modifi.destroy()
        Continuer()    
     
    def RetourMo() :
        global Modifi
        Modifi.destroy()
        Continuer()
     
    def Modif() :
        global varcombo, Manga, Modifi, ESynopsis,EEpisode,ENote,EEtat,EAvis
        Manga.destroy()
     
        Modifi=Tk()
        Modifi.title("MangaList")
        Modifi.geometry("350x360")
     
        fichier = open(varcombo.get()+".txt","r")
        info = fichier.read()
        ListeInfo = info.split("\n")
        fichier.close()
     
        Synopsis = ListeInfo[0]
        Episode = ListeInfo[1]
        Note = ListeInfo[2]
        Etat = ListeInfo[3]
        Avis = ListeInfo[4]
     
        if len(Synopsis)>=35 :
            Synopsis = Synopsis[:35]+"\n"+Synopsis[35:]
     
        if len(Avis)>=35 :
            Avis = Avis[:35] +"\n"+Avis[35:]
     
        LTitre = Label(Modifi,text="MangaList",font=("Comic Sans MS",18,"bold"))
        LNom = Label(Modifi,text="Nom : "+varcombo.get(),font=("Comic Sans MS",12))
        LSynopsis=Label(Modifi,text="Résumé : ",font=("Comic Sans MS",12))
        LEpisode = Label(Modifi,text="Ep : ",font=("Comic Sans MS",12))
        LNote = Label(Modifi,text="Note : ",font=("Comic Sans MS",12))
        LEtat = Label(Modifi,text="Etat : ",font=("Comic Sans MS",12))
        LAvis = Label(Modifi,text="Avis : ", font=("Comic Sans MS",12))
        ESynopsis = Entry(Modifi,width=30)
        EEpisode = Entry(Modifi,width=10)
        ENote = Entry(Modifi,width=10)
        EEtat = Entry(Modifi,width=10)
        EAvis = Entry(Modifi,width=30)
        ESynopsis.insert(END,Synopsis)
        EEpisode.insert(END,Episode)
        ENote.insert(END,Note)
        EEtat.insert(END,Etat)
        EAvis.insert(END,Avis)
     
        LTitre.place(x=100,y=30)
        LNom.place(x=20,y=80)
        LSynopsis.place(x=20,y=130)
        LEpisode.place(x=220,y=80)
        LNote.place(x=20,y=200)
        LEtat.place(x=220,y=200)
        LAvis.place(x=20,y=250)
        ESynopsis.place(x=110,y=140)
        EEpisode.place(x=280,y=90)
        ENote.place(x=90,y=210)
        EEtat.place(x=280,y=210)
        EAvis.place(x=100,y=260)
     
        BModifier=Button(Modifi,text="Entrer",width=10,command=Modifie)
        BRetour=Button(Modifi,text="Retour",width=10,command=RetourMo)
     
        BModifier.place(x=70,y=320)
        BRetour.place(x=200,y=320)
     
        Modifi.mainloop()
     
    def RetourM() :
        global Manga
        Manga.destroy()
        Continuer()
     
    def Choix(e) :
        global varcombo, root, Manga
     
        root.destroy()
     
        try :
            Manga = Tk()
            Manga.title("MangaList")
            Manga.geometry("350x360")
     
     
            fichier = open(varcombo.get()+".txt","r")
            info = fichier.read()
            ListeInfo = info.split("\n")
            fichier.close()
     
            Synopsis = "Résumé : "+ListeInfo[0]
            Episode = "Ep : "+ListeInfo[1]
            Note = "Note : "+ListeInfo[2]
            Etat = "Etat : "+ListeInfo[3]
            Avis = "Avis : "+ListeInfo[4]
     
            LTitre = Label(Manga,text="MangaList",font=("Comic Sans MS",18,"bold"))
            LNom = Label(Manga,text="Nom : "+varcombo.get(),font=("Comic Sans MS",12))
     
            if len(Synopsis)>=35 :
                Synopsis = Synopsis[:35]+"\n"+Synopsis[35:]
     
            if len(Avis)>=35 :
                Avis = Avis[:35] +"\n"+Avis[35:]
     
            LSynopsis=Label(Manga,text=Synopsis,font=("Comic Sans MS",12))
            LEpisode = Label(Manga,text=Episode,font=("Comic Sans MS",12))
            LNote = Label(Manga,text=Note,font=("Comic Sans MS",12))
            LEtat = Label(Manga,text=Etat,font=("Comic Sans MS",12))
            LAvis = Label(Manga,text=Avis, font=("Comic Sans MS",12))
     
            BModifier=Button(Manga,text="Modifier",width=10,command=Modif)
            BRetour=Button(Manga,text="Retour",width=10,command=RetourM)
     
            LTitre.place(x=100,y=30)
            LNom.place(x=20,y=80)
            LSynopsis.place(x=20,y=130)
            LEpisode.place(x=220,y=80)
            LNote.place(x=20,y=200)
            LEtat.place(x=220,y=200)
            LAvis.place(x=20,y=250)
     
            BModifier.place(x=70,y=320)
            BRetour.place(x=200,y=320)
     
            Manga.mainloop()
        except :
            print("")
     
    def Ajou() :
        global EAjout, manga, Ajout, root
     
        Ajout = Tk()
        Ajout.title("MangaList")
        Ajout.geometry("300x200")
     
        LTitre = Label(Ajout,text="MangaList",font=("Comic Sans MS",18,"bold"))
        BRetour = Button(Ajout,text="Retour",width=10,command=RetourA)
     
        if EAjout.get() == "Manga a ajouter" or EAjout.get() in manga:
            LAvertissement = Label(Ajout,text="Veuillez remplir un \nnom du manga correct.", font=("Comic Sans MS",14,"bold"))
     
        else :
            try :
                fichier = open(EAjout.get()+".txt","w")
                fichier.write("Synopsis\n0/??\n0\nEC\nNone")
                fichier.close()
                LAvertissement = Label(Ajout,text="L'anime a été\ncréer sans problème.",font=("Comic Sans MS",14,"bold"))
            except :
                LAvertissement = Label(Ajout,text="L'anime n'a pas été\ncréer. Désolé.",font=("Comic Sans MS",14,"bold"))
     
        LTitre.place(x=80,y=30)
        LAvertissement.place(x=50,y=90)
        BRetour.place(x=100,y=150)
     
        root.destroy()
     
        Ajout.mainloop()
     
    def RetourS() :
        global Supprimer
     
        Supprimer.destroy()
        Continuer()
     
    def RetourA() :
        global Ajout
     
        Ajout.destroy()
        Continuer()
     
    def Supprime() :
        global ESupprimer, manga, root, Supprimer
     
        Supprimer = Tk()
        Supprimer.title("MangaList")
        Supprimer.geometry("300x200")
     
        LTitre = Label(Supprimer,text="MangaList",font=("Comic Sans MS",18,"bold"))
        BRetour = Button(Supprimer,text="Retour",width=10,command=RetourS)
     
        if ESupprimer.get()== "Manga a supprimer" or not ESupprimer.get()+".txt" in manga:
            LAvertissement = Label(Supprimer,text="Veuillez remplir un \nnom du manga correct.", font=("Comic Sans MS",14,"bold"))
     
        else :
            try :
                os.remove(ESupprimer.get()+".txt")
                LAvertissement = Label(Supprimer,text="L'anime a été\nsupprimer sans problème.",font=("Comic Sans MS",14,"bold"))
            except :
                LAvertissement = Label(Supprimer,text="L'anime n'a pas été\nsupprimer. Désolé.",font=("Comic Sans MS",14,"bold"))
     
        BRetour.place(x=100,y=150)
        LTitre.place(x=80,y=30)
        LAvertissement.place(x=50,y=90)
     
        root.destroy()
     
        Supprimer.mainloop()
     
    def RetourR():
        global root
        root.destroy()
        Me()
     
    def Continuer() :
        global EAjout, ESupprimer, manga, root, varcombo
        root = tix.Tk()
        root.title("MangaList")
        root.geometry("290x350")
     
        LTitre = Label(root,text="MangaList",font=("Comic Sans MS",18,"bold"))
        LChoix = Label(root,text="Choisissez un manga :",font=("Comic Sans MS",12,"bold"))
        EAjout = Entry(root)
        EAjout.insert(END,'Manga a ajouter')
        BAjout = Button(root,text="Ajouter un manga",width = 16,command=Ajou)
        ESupprimer = Entry(root)
        ESupprimer.insert(END,'Manga a supprimer')
        BSupprimer = Button(root,text="Supprimer un manga",width = 16, command = Supprime)
        BRetour = Button(root,text="Retour",width=16,command = RetourR)
     
        varcombo = tix.StringVar() 
        combo = tix.ComboBox(root, editable=1, dropdown=1, variable=varcombo, command = Choix)
        combo.entry.config(state='readonly')
     
        manga=glob.glob("*.txt")
     
        for i in range(0,len(manga)) :
            Liste=manga[i].split(".")
            combo.insert(i,Liste[0]) 
     
        EAjout.place(x=70,y=155)
        BAjout.place(x=70,y=180)
        ESupprimer.place(x=70,y=225)
        BSupprimer.place(x=70,y=250)
        BRetour.place(x=70,y=295)
        LTitre.place(x=70,y=20)
        LChoix.place(x=50,y=70)
        combo.place(x=60,y=110)
     
        root.mainloop()
     
    def Continueer() :
        Menu.destroy()
        if not os.path.isdir('Fichier') :
            os.mkdir('Fichier')
        os.chdir('Fichier')
        Continuer()
     
    def Quitter() :
        global Menu
        Menu.destroy()
     
    def Me():
        global Menu
     
        Menu = Tk()
        Menu.title("MangaList")
        Menu.geometry("240x170")
     
        LTitre = Label(Menu,text="MangaList",font=("Comic Sans MS",18,"bold"))
        BContinuer = Button(Menu,text="Continuer",width = 10,command=Continueer)
        BQuitter = Button(Menu,text="Quitter",width=10,command=Quitter)
     
        LTitre.place(x=60,y=20)
        BContinuer.place(x=80,y=80)
        BQuitter.place(x=80,y=120)
     
        Menu.mainloop()
     
    Me()
    Mais il y a un autre bug :
    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
    Exception in Tkinter callback
    Traceback (most recent call last):
      File "C:\Users\LavaPower\AppData\Local\Programs\Python\Python35-32\lib\tkinter\__init__.py", line 1549, in __call__
        return self.func(*args)
      File "D:\Programmation\Python\Interface\MangaList\MangaList.py", line 265, in Continueer
        Continuer()
      File "D:\Programmation\Python\Interface\MangaList\MangaList.py", line 240, in Continuer
        combo = tix.ComboBox(root, editable=1, dropdown=1, variable=varcombo, command = Choix)
      File "C:\Users\LavaPower\AppData\Local\Programs\Python\Python35-32\lib\tkinter\tix.py", line 581, in __init__
        cnf, kw)
      File "C:\Users\LavaPower\AppData\Local\Programs\Python\Python35-32\lib\tkinter\tix.py", line 322, in __init__
        Widget.config(self, cnf)
      File "C:\Users\LavaPower\AppData\Local\Programs\Python\Python35-32\lib\tkinter\__init__.py", line 1330, in configure
        return self._configure('configure', cnf, kw)
      File "C:\Users\LavaPower\AppData\Local\Programs\Python\Python35-32\lib\tkinter\__init__.py", line 1321, in _configure
        self.tk.call(_flatten((self._w, cmd)) + self._options(cnf))
    _tkinter.TclError: can't invoke "winfo" command: application has been destroyed

  5. #5
    Expert éminent sénior
    Homme Profil pro
    Architecte technique retraité
    Inscrit en
    Juin 2008
    Messages
    21 287
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Manche (Basse Normandie)

    Informations professionnelles :
    Activité : Architecte technique retraité
    Secteur : Industrie

    Informations forums :
    Inscription : Juin 2008
    Messages : 21 287
    Points : 36 776
    Points
    36 776
    Par défaut
    Salut,

    Vous ne devez avoir qu'une instance de Tk dans votre application qui doit être créée au démarrage. Les autres appels Tk() doivent être remplacés par Toplevel().

    - W
    Architectures post-modernes.
    Python sur DVP c'est aussi des FAQs, des cours et tutoriels

  6. #6
    Membre à l'essai
    Homme Profil pro
    Étudiant
    Inscrit en
    Février 2015
    Messages
    27
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Vaucluse (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Février 2015
    Messages : 27
    Points : 23
    Points
    23
    Par défaut
    D'accord mais il est impossible de faire tix.Toplevel sinon il me dit :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    Exception in Tkinter callback
    Traceback (most recent call last):
      File "C:\Users\LavaPower\AppData\Local\Programs\Python\Python35-32\lib\tkinter\__init__.py", line 1549, in __call__
        return self.func(*args)
      File "F:\Programmation\Python\Interface\MangaList\MangaList.py", line 265, in Continueer
        Continuer()
      File "F:\Programmation\Python\Interface\MangaList\MangaList.py", line 240, in Continuer
        combo = tix.ComboBox(root, editable=1, dropdown=1, variable=varcombo, command = Choix)
      File "C:\Users\LavaPower\AppData\Local\Programs\Python\Python35-32\lib\tkinter\tix.py", line 581, in __init__
        cnf, kw)
      File "C:\Users\LavaPower\AppData\Local\Programs\Python\Python35-32\lib\tkinter\tix.py", line 318, in __init__
        self.tk.call(widgetName, self._w, *extra)
    _tkinter.TclError: invalid command name "tixComboBox"

  7. #7
    Expert éminent sénior
    Homme Profil pro
    Architecte technique retraité
    Inscrit en
    Juin 2008
    Messages
    21 287
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Manche (Basse Normandie)

    Informations professionnelles :
    Activité : Architecte technique retraité
    Secteur : Industrie

    Informations forums :
    Inscription : Juin 2008
    Messages : 21 287
    Points : 36 776
    Points
    36 776
    Par défaut
    Citation Envoyé par LavaPower Voir le message
    D'accord mais il est impossible de faire tix.Toplevel sinon il me dit :
    tix est une extension de tk, les widgets tix qui ne sont pas "enrichis" par tix peuvent être accédés directement.

    - W
    Architectures post-modernes.
    Python sur DVP c'est aussi des FAQs, des cours et tutoriels

  8. #8
    Membre à l'essai
    Homme Profil pro
    Étudiant
    Inscrit en
    Février 2015
    Messages
    27
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Vaucluse (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Février 2015
    Messages : 27
    Points : 23
    Points
    23
    Par défaut
    Désolé de te dire ça mais j'ai absolument rien compris de ta phrase

  9. #9
    Expert éminent sénior
    Homme Profil pro
    Architecte technique retraité
    Inscrit en
    Juin 2008
    Messages
    21 287
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Manche (Basse Normandie)

    Informations professionnelles :
    Activité : Architecte technique retraité
    Secteur : Industrie

    Informations forums :
    Inscription : Juin 2008
    Messages : 21 287
    Points : 36 776
    Points
    36 776
    Par défaut
    Citation Envoyé par LavaPower Voir le message
    Désolé de te dire ça mais j'ai absolument rien compris de ta phrase
    Avec un peu de code peut être?
    creation de l'application et de la première fenêtre:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    >>> from tkinter import tix
    >>> root = tix.Tk()
    creation des fenêtres suivantes:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    >>> import tkinter as tk
    >>> w = tk.Toplevel(root)
    Il vous faut aussi revoir les appels à .destroy car vous n'êtes supposé détruire l'instance de Tk qu'a la sortie de l'application.

    - W
    Architectures post-modernes.
    Python sur DVP c'est aussi des FAQs, des cours et tutoriels

  10. #10
    Membre à l'essai
    Homme Profil pro
    Étudiant
    Inscrit en
    Février 2015
    Messages
    27
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Vaucluse (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Février 2015
    Messages : 27
    Points : 23
    Points
    23
    Par défaut
    Le problème est que la fenetre root n'est pas la première, c'est la deuxième

    EDIT : malgré ça, j'ai fais :

    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
    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
    from tkinter import *
    from tkinter import tix
    from tkinter.constants import *
    from tkinter.messagebox import *
    import os, glob
     
    def Modifie() :
        global ESynopsis,EEpisode,ENote,EEtat,EAvis,varcombo,Modifi
        try :
            fichier=open(varcombo.get()+".txt","w")
            fichier.write(ESynopsis.get()+"\n"+EEpisode.get()+"\n"+ENote.get()+"\n"+EEtat.get()+"\n"+EAvis.get())
            fichier.close()
            showinfo('MangaList','Modification effectué\nMerci !')
        except:
            showwarning('MangaList','Modification raté !\n Désolé !')
        Modifi.quit()
        Continuer()    
     
    def RetourMo() :
        global Modifi
        Modifi.quit()
        Continuer()
     
    def Modif() :
        global varcombo, Manga, Modifi, ESynopsis,EEpisode,ENote,EEtat,EAvis
        Manga.quit()
     
        Modifi=Toplevel(Manga)
        Modifi.title("MangaList")
        Modifi.geometry("350x360")
     
        fichier = open(varcombo.get()+".txt","r")
        info = fichier.read()
        ListeInfo = info.split("\n")
        fichier.close()
     
        Synopsis = ListeInfo[0]
        Episode = ListeInfo[1]
        Note = ListeInfo[2]
        Etat = ListeInfo[3]
        Avis = ListeInfo[4]
     
        if len(Synopsis)>=35 :
            Synopsis = Synopsis[:35]+"\n"+Synopsis[35:]
     
        if len(Avis)>=35 :
            Avis = Avis[:35] +"\n"+Avis[35:]
     
        LTitre = Label(Modifi,text="MangaList",font=("Comic Sans MS",18,"bold"))
        LNom = Label(Modifi,text="Nom : "+varcombo.get(),font=("Comic Sans MS",12))
        LSynopsis=Label(Modifi,text="Résumé : ",font=("Comic Sans MS",12))
        LEpisode = Label(Modifi,text="Ep : ",font=("Comic Sans MS",12))
        LNote = Label(Modifi,text="Note : ",font=("Comic Sans MS",12))
        LEtat = Label(Modifi,text="Etat : ",font=("Comic Sans MS",12))
        LAvis = Label(Modifi,text="Avis : ", font=("Comic Sans MS",12))
        ESynopsis = Entry(Modifi,width=30)
        EEpisode = Entry(Modifi,width=10)
        ENote = Entry(Modifi,width=10)
        EEtat = Entry(Modifi,width=10)
        EAvis = Entry(Modifi,width=30)
        ESynopsis.insert(END,Synopsis)
        EEpisode.insert(END,Episode)
        ENote.insert(END,Note)
        EEtat.insert(END,Etat)
        EAvis.insert(END,Avis)
     
        LTitre.place(x=100,y=30)
        LNom.place(x=20,y=80)
        LSynopsis.place(x=20,y=130)
        LEpisode.place(x=220,y=80)
        LNote.place(x=20,y=200)
        LEtat.place(x=220,y=200)
        LAvis.place(x=20,y=250)
        ESynopsis.place(x=110,y=140)
        EEpisode.place(x=280,y=90)
        ENote.place(x=90,y=210)
        EEtat.place(x=280,y=210)
        EAvis.place(x=100,y=260)
     
        BModifier=Button(Modifi,text="Entrer",width=10,command=Modifie)
        BRetour=Button(Modifi,text="Retour",width=10,command=RetourMo)
     
        BModifier.place(x=70,y=320)
        BRetour.place(x=200,y=320)
     
        Modifi.mainloop()
     
    def RetourM() :
        global Manga
        Manga.quit()
        Continuer()
     
    def Choix(e) :
        global varcombo, root, Manga
     
        root.quit()
     
        try :
            Manga = Toplevel(root)
            Manga.title("MangaList")
            Manga.geometry("350x360")
     
     
            fichier = open(varcombo.get()+".txt","r")
            info = fichier.read()
            ListeInfo = info.split("\n")
            fichier.close()
     
            Synopsis = "Résumé : "+ListeInfo[0]
            Episode = "Ep : "+ListeInfo[1]
            Note = "Note : "+ListeInfo[2]
            Etat = "Etat : "+ListeInfo[3]
            Avis = "Avis : "+ListeInfo[4]
     
            LTitre = Label(Manga,text="MangaList",font=("Comic Sans MS",18,"bold"))
            LNom = Label(Manga,text="Nom : "+varcombo.get(),font=("Comic Sans MS",12))
     
            if len(Synopsis)>=35 :
                Synopsis = Synopsis[:35]+"\n"+Synopsis[35:]
     
            if len(Avis)>=35 :
                Avis = Avis[:35] +"\n"+Avis[35:]
     
            LSynopsis=Label(Manga,text=Synopsis,font=("Comic Sans MS",12))
            LEpisode = Label(Manga,text=Episode,font=("Comic Sans MS",12))
            LNote = Label(Manga,text=Note,font=("Comic Sans MS",12))
            LEtat = Label(Manga,text=Etat,font=("Comic Sans MS",12))
            LAvis = Label(Manga,text=Avis, font=("Comic Sans MS",12))
     
            BModifier=Button(Manga,text="Modifier",width=10,command=Modif)
            BRetour=Button(Manga,text="Retour",width=10,command=RetourM)
     
            LTitre.place(x=100,y=30)
            LNom.place(x=20,y=80)
            LSynopsis.place(x=20,y=130)
            LEpisode.place(x=220,y=80)
            LNote.place(x=20,y=200)
            LEtat.place(x=220,y=200)
            LAvis.place(x=20,y=250)
     
            BModifier.place(x=70,y=320)
            BRetour.place(x=200,y=320)
     
            Manga.mainloop()
        except :
            print("")
     
    def Ajou() :
        global EAjout, manga, Ajout, root
     
        Ajout = Toplevel(root)
        Ajout.title("MangaList")
        Ajout.geometry("300x200")
     
        LTitre = Label(Ajout,text="MangaList",font=("Comic Sans MS",18,"bold"))
        BRetour = Button(Ajout,text="Retour",width=10,command=RetourA)
     
        if EAjout.get() == "Manga a ajouter" or EAjout.get() in manga:
            LAvertissement = Label(Ajout,text="Veuillez remplir un \nnom du manga correct.", font=("Comic Sans MS",14,"bold"))
     
        else :
            try :
                fichier = open(EAjout.get()+".txt","w")
                fichier.write("Synopsis\n0/??\n0\nEC\nNone")
                fichier.close()
                LAvertissement = Label(Ajout,text="L'anime a été\ncréer sans problème.",font=("Comic Sans MS",14,"bold"))
            except :
                LAvertissement = Label(Ajout,text="L'anime n'a pas été\ncréer. Désolé.",font=("Comic Sans MS",14,"bold"))
     
        LTitre.place(x=80,y=30)
        LAvertissement.place(x=50,y=90)
        BRetour.place(x=100,y=150)
     
        root.quit()
     
        Ajout.mainloop()
     
    def RetourS() :
        global Supprimer
     
        Supprimer.quit()
        Continuer()
     
    def RetourA() :
        global Ajout
     
        Ajout.quit()
        Continuer()
     
    def Supprime() :
        global ESupprimer, manga, root, Supprimer
     
        Supprimer = Toplevel(root)
        Supprimer.title("MangaList")
        Supprimer.geometry("300x200")
     
        LTitre = Label(Supprimer,text="MangaList",font=("Comic Sans MS",18,"bold"))
        BRetour = Button(Supprimer,text="Retour",width=10,command=RetourS)
     
        if ESupprimer.get()== "Manga a supprimer" or not ESupprimer.get()+".txt" in manga:
            LAvertissement = Label(Supprimer,text="Veuillez remplir un \nnom du manga correct.", font=("Comic Sans MS",14,"bold"))
     
        else :
            try :
                os.remove(ESupprimer.get()+".txt")
                LAvertissement = Label(Supprimer,text="L'anime a été\nsupprimer sans problème.",font=("Comic Sans MS",14,"bold"))
            except :
                LAvertissement = Label(Supprimer,text="L'anime n'a pas été\nsupprimer. Désolé.",font=("Comic Sans MS",14,"bold"))
     
        BRetour.place(x=100,y=150)
        LTitre.place(x=80,y=30)
        LAvertissement.place(x=50,y=90)
     
        root.quit()
     
        Supprimer.mainloop()
     
    def RetourR():
        global root
        root.quit()
        Me()
     
    def Continuer() :
        global EAjout, ESupprimer, manga, root, varcombo, Menu
        root = tix.Tk()
        root.title("MangaList")
        root.geometry("290x350")
     
        LTitre = Label(root,text="MangaList",font=("Comic Sans MS",18,"bold"))
        LChoix = Label(root,text="Choisissez un manga :",font=("Comic Sans MS",12,"bold"))
        EAjout = Entry(root)
        EAjout.insert(END,'Manga a ajouter')
        BAjout = Button(root,text="Ajouter un manga",width = 16,command=Ajou)
        ESupprimer = Entry(root)
        ESupprimer.insert(END,'Manga a supprimer')
        BSupprimer = Button(root,text="Supprimer un manga",width = 16, command = Supprime)
        BRetour = Button(root,text="Retour",width=16,command = RetourR)
     
        varcombo = tix.StringVar() 
        combo = tix.ComboBox(root, editable=1, dropdown=1, variable=varcombo, command = Choix)
        combo.entry.config(state='readonly')
     
        manga=glob.glob("*.txt")
     
        for i in range(0,len(manga)) :
            Liste=manga[i].split(".")
            combo.insert(i,Liste[0]) 
     
        EAjout.place(x=70,y=155)
        BAjout.place(x=70,y=180)
        ESupprimer.place(x=70,y=225)
        BSupprimer.place(x=70,y=250)
        BRetour.place(x=70,y=295)
        LTitre.place(x=70,y=20)
        LChoix.place(x=50,y=70)
        combo.place(x=60,y=110)
     
        root.mainloop()
     
    def Continueer() :
        Menu.quit()
        if not os.path.isdir('Fichier') :
            os.mkdir('Fichier')
        os.chdir('Fichier')
        Continuer()
     
    def Quitter() :
        global Menu
        Menu.destroy()
     
    def Me():
        global Menu
     
        Menu = Tk()
        Menu.title("MangaList")
        Menu.geometry("240x170")
     
        LTitre = Label(Menu,text="MangaList",font=("Comic Sans MS",18,"bold"))
        BContinuer = Button(Menu,text="Continuer",width = 10,command=Continueer)
        BQuitter = Button(Menu,text="Quitter",width=10,command=Quitter)
     
        LTitre.place(x=60,y=20)
        BContinuer.place(x=80,y=80)
        BQuitter.place(x=80,y=120)
     
        Menu.mainloop()
     
    Me()
    Mais les fenetres s'accumulent

  11. #11
    Expert éminent sénior
    Homme Profil pro
    Architecte technique retraité
    Inscrit en
    Juin 2008
    Messages
    21 287
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Manche (Basse Normandie)

    Informations professionnelles :
    Activité : Architecte technique retraité
    Secteur : Industrie

    Informations forums :
    Inscription : Juin 2008
    Messages : 21 287
    Points : 36 776
    Points
    36 776
    Par défaut
    Salut

    En français "revoir" signifie reconsidérer l'utilisation là vous avez remplacé tout les appels à .destroy() par des appels à .quit().
    Pour le reste, vous gérez très mal l’enchaînement de ce qui se passe à l'écran.
    Problème, ce que vous voulez faire est passablement compliqué pour votre niveau de programmation. Dit autrement, sans maîtrisez comment vous simplifier la vie le machin est ingérable. Ceci dit, comme je ne veux pas toucher à votre code, la seule chose que je peux vous proposer est un exemple de technique:

    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
    import tkinter as tk
     
    def display(master, color):
        rs = 0
     
        def do_prev():
            nonlocal rs
            rs = -1
            master.quit()
     
        def do_next():
            nonlocal rs
            rs = 1
            master.quit()
     
        widget = tk.Frame(master, bg=color, height=200, width=200)
        widget.pack()
        widget.pack_propagate(0)
        tk.Button(widget, text='next', command=do_next).pack(side='right')
        tk.Button(widget, text='prev', command=do_prev).pack(side='left')
        master.mainloop()
        widget.destroy()
        return rs
     
    if __name__ == '__main__':
        root = tk.Tk()
        colors = ('blue', 'red', 'grey', 'green')
        index = 0
        while True:
            color = colors[index]
            rs = display(root, color)
     
            index += rs
            if index < 0: index = 0
            if index >= len(colors): index = len(colors) - 1
    Ca ne fait pas grand chose de compliqué sinon de se changer de Frame qu'on voit grace aux couleurs.
    Ce qu'il faut regarder c'est comment j'utilise les fonctiins imbriquées pour éviter la collision des noms (vos Continueer, Continuer,...).
    L'intérêt de mainloop/quit est qu'on peut transformer une procédure en fonction qui retourne quelque chose.
    A partir de là on peut "centraliser" le contrôle du déroulé et retrouver ses petits un peu mieux.

    Essayez de comprendre comment çà fonctionne pour vous en inspirer.

    - W
    Architectures post-modernes.
    Python sur DVP c'est aussi des FAQs, des cours et tutoriels

  12. #12
    Membre à l'essai
    Homme Profil pro
    Étudiant
    Inscrit en
    Février 2015
    Messages
    27
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Vaucluse (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Février 2015
    Messages : 27
    Points : 23
    Points
    23
    Par défaut Un autre problème
    Très bien, je vais essayer de comprendre mais j'ai un autre problème.

    Avec ce code simple :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    from tkinter.messagebox import *
     
    showwarning("Test","test")
    La popup est bien crée mais une fenetre normal Tk() est aussi crée

  13. #13
    Expert éminent sénior
    Homme Profil pro
    Architecte technique retraité
    Inscrit en
    Juin 2008
    Messages
    21 287
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Manche (Basse Normandie)

    Informations professionnelles :
    Activité : Architecte technique retraité
    Secteur : Industrie

    Informations forums :
    Inscription : Juin 2008
    Messages : 21 287
    Points : 36 776
    Points
    36 776
    Par défaut
    Salut,

    Citation Envoyé par LavaPower Voir le message
    La popup est bien crée mais une fenetre normal Tk() est aussi crée
    Normal showwarning crée un Toplevel et a besoin de démarrer l'application (i.e. effectuer le Tk() que vous n'avez pas fait explicitement).

    - W
    Architectures post-modernes.
    Python sur DVP c'est aussi des FAQs, des cours et tutoriels

  14. #14
    Membre à l'essai
    Homme Profil pro
    Étudiant
    Inscrit en
    Février 2015
    Messages
    27
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Vaucluse (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Février 2015
    Messages : 27
    Points : 23
    Points
    23
    Par défaut
    Merci beaucoup pour ton aide

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [Projet] Problème incompréhensible
    Par NeuroGen dans le forum Général Python
    Réponses: 3
    Dernier message: 18/03/2006, 00h02
  2. Problème incompréhensible! Fichier + liste
    Par djsbens dans le forum C
    Réponses: 2
    Dernier message: 07/12/2005, 00h30
  3. problème de suite pair et impair
    Par florane dans le forum C
    Réponses: 13
    Dernier message: 18/10/2005, 13h51
  4. Problème incompréhensible
    Par bugalood dans le forum Langage
    Réponses: 2
    Dernier message: 15/09/2005, 11h49
  5. Problème affichage suite jointure
    Par xavier1977 dans le forum Langage SQL
    Réponses: 4
    Dernier message: 12/07/2005, 15h00

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