bonjour


Sur python 3.4 pas d'erreur, mais sur python 3.9 j'ai une erreur
Voici l'erreur
Merci pour vos réponses
Cordialement

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
Python 3.9.1 (tags/v3.9.1:1e5d33e, Dec  7 2020, 17:08:21) [MSC v.1927 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>> 
=================== RESTART: C:\Users\rico\Desktop\essais.py ===================
Exception in Tkinter callback
Traceback (most recent call last):
  File "C:\Users\rico\AppData\Local\Programs\Python\Python39\lib\tkinter\__init__.py", line 1884, in __call__
    return self.func(*args)
  File "C:\Users\rico\Desktop\essais.py", line 165, in clic_choix
    self.E4.insert(0,self.lisbox_choix.get(index))
  File "C:\Users\rico\AppData\Local\Programs\Python\Python39\lib\tkinter\__init__.py", line 3183, in get
    return self.tk.call(self._w, 'get', first)
_tkinter.TclError: bad listbox index "": must be active, anchor, end, @x,y, or a number


Code python : 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
 
from tkinter import ttk
from tkinter import *
 
fenetre=Tk()
fenetre.title("BANQUE")
fenetre.geometry("1250x700+10+10")
 
#fenetre.update_idletask()
width = fenetre.winfo_width()
height = fenetre.winfo_height()
 
width = 1250
height = 700
 
x = (fenetre.winfo_screenwidth()//2)-(width//2)
y = (fenetre.winfo_screenheight()//2)-(height//2)
fenetre.geometry('{}x{}+{}+{}'.format(width,height,x,y))
 
 
                ###################################
                ##########                 ########
                ##########     DEBUT       ########
                ##########    TABLEAU      ########                 
                ##########      TOUS       ########
                ##########                 ######## 
                ###################################
 
class   Tableau_Tous:
    def __init__(self):
 
        """Constructeur de la fenêtre principale"""
 
                    #####################
 
            # ENTETE TABLEAU 
        self.Frame1= Frame(fenetre)
        self.Frame1.grid(row=0, column=0,padx=5,pady=5 )
 
            #####################
 
            # ENTETE TABLEAU 
        self.Frame2= Frame(fenetre)
        self.Frame2.grid(row=1, column=0,padx=0,pady=0 )
 
            #####################
 
            # LABEL RECUP CHOIX
        self.Frame3= Frame(fenetre)
        self.Frame3.grid(row=2, column=0,padx=5,pady=5 )
 
            #####################
 
            # LISBOX
        self.Frame4= Frame(fenetre)
        self.Frame4.grid(row=3, column=0,padx=5,pady=5 )
 
            #######################
             # BOUTON
        self.Frame7 = Frame(fenetre)
        self.Frame7.grid(row=6, column=0,padx=0,pady=5 )
 
            ########################
 
        label=Label(self.Frame1,text = "TABLEAU" ,fg='red',bg='yellow',
                        font=("arial",15,"bold italic"))
        label.grid(row=0,column=0,columnspan=8)                    
 
            # Bouton  "Terminer"      
        bt_terminer = Button(self.Frame7,text='Terminer',bg='green3',
                font=("arial",12,"bold italic"),fg='black',
                command = Vider_Frame)
        bt_terminer.grid(row=0,column=3,padx=50)
 
            # appel la fonction <remplissage_liste>
        self.remplissage_liste()
 
            ######## ENTETE DU TABLEAU ######################          
 
        L4 = Label(self.Frame2, text="Choix\n",
                relief=RIDGE,width=11,fg='yellow',bg='red',
                font=("arial",12,"bold italic"))
        L4.grid(row=0,column=3,padx=3)        
 
        L7 = Label(self.Frame2,text="Bénéficiaire\n",
                relief=RIDGE,width=17,fg='yellow',bg='red',
                font=("arial",12,"bold italic"))
        L7.grid(row=0,column=6,padx=3)
 
 
                # Fin entête du tableau
 
    ################################################################                               
 
        self.E4 = Entry(self.Frame3, 
                relief=RIDGE,width=13,fg='red',bg='yellow',
                justify='center',font=("arial",12,"bold italic"))
        self.E4.grid(row=0,column=3,padx=5)
        self.E4.insert(0,"Tous")         
 
        self.E7 = Entry(self.Frame3,#Bénéficiaire
                relief=RIDGE,width=21,fg='red',bg='yellow',
                justify='center',font=("arial",12,"bold italic"))
        self.E7.grid(row=0,column=6,padx=5)
        self.E7.insert(0,"Tous")         
 
            #################
 
        self.toutes_les_listbox()#appel fonction
 
 
 
    def toutes_les_listbox(self):       
 
            ################# lISTBOX CHOIX ##########################
 
            self.barre = Scrollbar(self.Frame4, orient=VERTICAL)
            self.lisbox_choix = Listbox(self.Frame4,bg='chartreuse',fg='blue',
                height=5,width=11,font=("arial",12,"bold italic"))
            self.barre.config(command = self.lisbox_choix.yview)
            self.lisbox_choix.config(yscrollcommand = self.barre.set, )
            self.lisbox_choix.grid(column=6, row=0,padx=5)
            self.barre.grid(column=7, row=0, sticky=S+N)
 
            for x in self.liste_choix:
                self.lisbox_choix.insert(END,x)
 
            self.lisbox_choix.bind("<<ListboxSelect>>", self.clic_choix)
 
 
 
            ################# lISTBOX BENEFICIAIRE ##########################
 
            self.barre = Scrollbar(self.Frame4, orient=VERTICAL)
            self.lisbox_select = Listbox(self.Frame4,bg='chartreuse',fg='blue',
                height=5,width=19,font=("arial",12,"bold italic"))
            self.barre.config(command = self.lisbox_select.yview)
            self.lisbox_select.config(yscrollcommand = self.barre.set, )
            self.lisbox_select.grid(column=12, row=0,padx=5) 
            self.barre.grid(column=13, row=0, sticky=S+N)
 
            for x in self.liste_select:
                self.lisbox_select.insert(END,x)
 
            self.lisbox_select.bind("<<ListboxSelect>>", self.clic_select)
 
 
    def remplissage_liste(self):       
 
        self.liste_choix = []
        self.liste_select = []
 
 
        self.liste_choix = ['Carte','Cheque','Virement','Prelevement']
        self.liste_choix.insert(0,'Tous')
 
        self.liste_select = ['carrefour','lidl','geant','superU']
        self.liste_select.insert(0,'Tous')
 
 
    def clic_choix(self,evt):        
        # Récupère le choix
        index = self.lisbox_choix.curselection()
        self.E4.config(state=NORMAL)# permet l'écriture
        self.E4.delete(0,END) # vide l'entry
        self.E4.insert(0,self.lisbox_choix.get(index))
        # Inscrit le choix dans l'Entry       
 
    def clic_select(self,evt):        
        # Récupère le choix
        index = self.lisbox_select.curselection()
        self.E7.config(state=NORMAL)# permet l'écriture
        self.E7.delete(0,END) # vide l'entry
        self.E7.insert(0,self.lisbox_select.get(index))
        # Inscrit le choix dans l'Entry
 
 
                 ###################################
                ##########                 ########
                ##########       FIN       ########
                ##########     TABLEAU     ########                 
                ##########       TOUS      ########                 
                ##########                 ######## 
                ###################################
 
            #################################
            ########                 ########
            ########  DEBUT CLASS    ########
            ########     VIDER       ########
            ########     FRAME       ########
            ########                 ########
            #################################       
 
class Vider_Frame :
    def __init__(self):
 
        for widget in fenetre.winfo_children():
            widget.grid_forget()
 
                #################################
                ########                 ########
                ########   FIN CLASS     ########
                ########     VIDER       ########
                ########     FRAME       ########
                ########                 ########
                #################################
 
menubar = Menu(fenetre)
 
######################## TABLEAU ####################
 
menu4 = Menu(menubar, tearoff=0)
menu4.add_command(label="Tous", command = Tableau_Tous)# 2195
 
menu4.add_separator()
menu4.add_command(label="Quitter", command=fenetre.quit)
 
menubar.add_cascade(label="Tableau", menu=menu4)
 
fenetre.config(menu=menubar)
 
fenetre.mainloop()