Bonjour à tous,
Je débute en python, et j'essaie avec TKinter de faire un truc qui semble pourtant simple : afficher 3 frames contenant chacune une lettre, et trois boutons ayant chacun une commande permettant de changer en rouge l'une des lettres...
Ce sera sans doute plus clair en voyant mon code... le voici :

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
from Tkinter import *
fen1 = Tk()
fram1 = Frame(fen1,height='20',width='20')
txt1 = Label(fram1,text='Y')
fram1.grid(row=0,column=0)
txt1.grid()
fram2 = Frame(fen1,height='20',width='20')
txt2 = Label(fram2,text='S')
fram2.grid(row=0,column=1)
txt2.grid()
fram3 = Frame(fen1,height='20',width='20')
txt3 = Label(fram3,text='D')
fram3.grid(row=0,column=2)
txt3.grid()
def colorer () :
	self.fg='red'
bou1 = Button(fen1,text='Colorer Y',command=colorer(txt1))
bou1.grid(row=1,column=0)
bou2 = Button(fen1,text='Colorer S',command=colorer(txt2))
bou2.grid(row=1,column=1)
bou3 = Button(fen1,text='Colorer D',command=colorer(txt3))
bou3.grid(row=1,column=2)
fen1.mainloop()
Tout s'affiche mais... au clic sur les boutons, rien ne se passe...
Quelqu'un saurait me dire pourquoi ?

Merci pour votre aide !