I am trying to understand GUI conception for python with Tkinter so this question might be very simple.. I am trying to add event listener to two Listboxes of prime numbers and display the two selected numbers in a label right under them. However, after binding the event handlers to the Listboxes an error appears during compiling. I can't understand why it is raised during compiling. So here is the part of my code where I create the listboxes, populate them and bind the event handlers (when I remove the binding the program compiles and the lists appear populated so it's not an empty list problem IMO) :
liste_gauche = Listbox(containeur_listes,width=20,height=20,bg='yellow',exportselection=False)
liste_gauche.grid(row=1,column=0,padx=10,pady=10)
liste_droite = Listbox(containeur_listes,width=20,height=20,bg='blue',exportselection=False)
liste_droite.grid(row=1,column=2,padx=10,pady=10)
for i in LIST_PRIMES:
liste_gauche.insert('end',i)
liste_droite.insert('end',i)
liste_gauche.bind("<ButtonRelease-1>",self.changeLabelNombre("gauche"))
liste_droite.bind("<ButtonRelease-1>",self.changeLabelNombre("droite"))
And the event handler :
def changeLabelNombre(self,cote):
if(cote == 'gauche'):
self.variable_gauche.config(text=self.liste_gauche.get(self.liste_gauche.curselection()))
else:
self.variable_droite.config(text=self.liste_droite.get(self.liste_droite.curselection()))
Thank you very much :)