1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| from tkinter import *
def Print():
labininstance['text'] = "Valeur pour l'instance:: width=%s, height=%s" % (can1["width"], can1["height"])
labreel['text'] = "Valeur reelle: width=%d, height=%d" % (can1.winfo_width(), can1.winfo_height())
def OnClic(e):
labverif['text'] = "Vérifier par clic: width=%d, height=%d" % (e.x, e.y)
fen1 = Tk()
can1 = Canvas(fen1, bg='white')
can1.pack(fill='both', expand=1)
labininstance = Label(fen1, text="Valeur pour l'instance:")
labininstance.pack(padx=5, pady=5)
labreel = Label(fen1, text='Valeur reelle:')
labreel.pack(padx=5, pady=5)
Button(fen1, text='test', command=Print).pack(padx=5, pady=5)
labverif = Label(fen1, text='Cliquez pour vérifier')
labverif.pack(padx=5, pady=5)
can1.bind("<1>", OnClic)
fen1.mainloop() |
Partager