O'Reilly logo

Tcl/Tk in a Nutshell by Paul Raines, Jeff Tranter

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

bind

bind tag [sequence [ [+] script] ]

Set or query event bindings. If all three arguments are specified, the Tcl script script will be evaluated whenever the event specified by the pattern sequence occurs in the windows identified by tag. If script is prefixed by the character "+", it is appended to any existing script bound to tag for sequence. Otherwise, any current script is replaced. If script is an empty string, any current binding to the event is destroyed.

If no script is specified, the script currently bound to tag for sequence is returned. If only tag is given, a list of all the sequences for which there exist bindings for tag is returned.

Binding Tags

The windows to which a binding applies are selected by the tag argument. If tag begins with the "." character, it must be a pathname for a window; otherwise, it can be an arbitrary string. Each window has an associated list of tags that can be manipulated with the bindtags command. The default tags for a newly created window, in priority order, are as follows:

  • The pathname of the window itself (e.g., .main.text). Binding to this tag will bind the sequence to that window only, unless the window is top-level.

  • The pathname of the top-level window containing the window (e.g., "."). Binding to this tag will bind the sequence to all windows contained by the top-level window.

  • The widget class of the window (e.g., Text). Binding to this tag will bind the sequence to all windows of that class. This is how the default bindings for all ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required