Problème avec .configure dans une classe
Bonjour bonjour.
J'ai un problème : lorsque j'utilise la méthode .configure sur un label, tout marche bien, mais lorsque je rentre le tout dans une classe, ça se passe mal. Voici mon code :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| # -*- coding:Utf-8 -*-
from Tkinter import *
class Application(Tk):
def __init__(self):
Tk.__init__(self)
texte = Label(self, text='Hello', width=100)
texte.pack()
Button(self, text='Essai', command=self.affiche_fichier).pack()
Button(self, text='Quitter', command=self.destroy).pack()
texte.configure(text="oueee")
def affiche_fichier(self):
self.texte.configure(texte="gagne")
if __name__ == '__main__':
Application().mainloop() |
Lorsque j'exécute, le champ indique oueee, mais il y a une erreur lorsque je clique sur le bouton :
Citation:
Exception in Tkinter callback
Traceback (most recent call last):
File "lib-tk/Tkinter.py", line 1406, in __call__
return self.func(*args)
File "prets.py", line 19, in affiche_fichier
self.texte.configure(texte="Brol")
File "lib-tk/Tkinter.py", line 1724, in __getattr__
return getattr(self.tk, attr)
AttributeError: texte
Quelqu'un voit-il la bêtise que je fais ? :o
Merci d'avance pour vos éclairantes lumières.
Instanton