The bind method from the widget command allows you to watch for certain events and to have a callback function trigger when that event type occurs. The form of the bind method is:
def bind(self, sequence, func, add=''):
For example:
def turnRed(self, event): event.widget["activeforeground"] = "red" self.button.bind("<Enter>", self.turnRed)
Notice how the widget field of the event is being accessed in the turnRed() callback. This field contains the widget that caught the X event. The following table lists the other event fields you can access, and how they are denoted in Tk, which can be useful when referring to the Tk man pages.
Tk Tkinter Event Field Tk Tkinter Event Field -- ------------------- -- ------------------- %f focus %A char %h height %E send_event %k keycode %K keysym %s state %N keysym_num %t time %T type %w width %W widget %x x %X x_root %y y %Y y_root
See About this document... for information on suggesting changes.