change color

Ben Bush pythonnew at gmail.com
Mon Dec 5 02:52:52 CET 2005


I tested the following code and wanted to make oval 2 become red after
I hit the enter key but though the code did not report error, it did
not change.
from Tkinter import *
root=Tk()
canvas=Canvas(root,width=100,height=100)
canvas.pack()
canvas.create_oval(10,10,20,20,tags='oval1',fill='blue')
canvas.create_oval(50,50,80,80,tags='oval2',fill='yellow')
def turnRed(self, event):
    event.widget["activeforeground"] = "red"
    self.button.bind("<Enter>", self.turnRed)
canvas.tag_bind('oval2',func=turnRed)
root.mainloop()



More information about the Python-list mailing list