# -*- coding: cp1252 -*- from Tkinter import * from tkColorChooser import askcolor def setBgColor(): """ Fonction utilisée dans l'événement clique du bouton """ (rgb, hexstr) = askcolor() # Appel de la boîte de dialogue 'Couleur' if hexstr: print 'Hexadécimal: ', hexstr print 'RGB: ',rgb widget.config(bg=hexstr) mainForm = Tk() widget = Button(mainForm, text='Modifier la Couleur', command=setBgColor) #Configuration du widget widget.config(height=3, font=('times', 20, 'bold'), bd=8, relief=RAISED) widget.pack(expand=YES, fill=BOTH) mainForm.mainloop()