Next / Previous / Contents / Shipman's homepage

54.8. Virtual events

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 w will trigger the handler h.

See .event_add(), .event_delete(), and .event_info() under Section 26, “Universal widget methods” for more information about creating and managing virtual events.