Navigation Logo Bindings Navigation Logo

 

 

Bindings are the name given to connections between events and event handlers. For example, because of a binding an entry widget has an event handler ready to handle a character when an appropriate keyboard event happens. This binding is established by default when an entry widget is created. Tk's default bindings will serve most of your purposes but most scripts seem to require that a few additional bindings be created.

Tcl supports I/O and timer events as discussed above in The Event Loop. The Tk programmer may not have a need for these things. But the Tk programmer does need to work with user and user-related events because they initiate actions by Tk's widgets. A user event is generated by a keyboard or mouse action. A user-related event is a user event or it is deduced by Tk from user-related events. For example, the movement of a mouse cursor into or out of the screen area displaying a particular widget is a user-related event.

Bindings arrange for scripts called event handlers to be triggered, that is, to go on an event queue, when a particular kind of event happens. Tk executes the event handlers on the event queue, one by one, when it can. Unlike Tcl, Tk is always event-driven. Event-driven programming may cause timing problems. Some solutions are discussed in the last section of this chapter. If those aren't sufficient, you should read The Event Loop and More about the Event Loop above very carefully.

  • User Events
  • Getting Information to Event Handlers
  • Bindings
  • More about Bindings
  • Timing
  • Solutions to Exercises
 

 

[Sample TK Application]
Author's Home Page
Navigation Logo [Book's Cover]
Order from Amazon.