This is an unofficial mirror of Tkinter reference documentation (based on Python 2.7 and Tk 8.5) created by the late John Shipman.
It was last updated in 2013 and is unmaintained. [More info]
You can create your own new kinds of events called
virtual events. You can give them
any name you want so long as it is enclosed in double
pairs of <<…>>
.
For example, suppose you want to create a new event
called <<panic>>
, that is
triggered either by mouse button 3 or by the
pause key. To create this event, call
this method on any widget
:
w
w
.event_add('<<panic>>', '<Button-3>',
'<KeyPress-Pause>')
You can then use '<<panic>>'
in any event sequence. For example, if you use this
call:
w
.bind('<<panic>>',h
)
any mouse button 3 or pause keypress in
widget
will trigger the handler w
.
h
See .event_add()
, .event_delete()
, and .event_info()
under Section 26, “Universal widget methods” for more information
about creating and managing virtual events.