1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| from tkinter import *
def enterTag(obj, id):
root.title(id)
def leaveTag(obj, id):
root.title('')
root = Tk()
can = Canvas(root,bg="gold")
can.grid(row=1,column=1)
can.create_oval(10,10,125,125)
for index in range(1, 11):
lab_id = can.create_text(10, 20 * index, text='label_%02i'%index, anchor="nw")
can.tag_bind ( lab_id, '<Enter>', lambda obj=can, id=lab_id:enterTag(obj, id))
can.tag_bind ( lab_id, '<Leave>', lambda obj=can, id=lab_id:leaveTag(obj, id))
scl = Scrollbar(root,command=can.yview)
scl.grid(row=1,column=2,sticky=NS)
root.mainloop() |
Partager