Configuring Attributes

You specify attributes for Tk widgets when you create them. You can also change them dynamically at any time after that. In both cases the syntax uses pairs of arguments. The first item in the pair identifies the attribute, the second provides the value. For example, a button can be created like this:

button .doit -text Doit -command DoSomething

The name of the button is .doit, and two attributes are specified: the text and the command. You can change the .doit button later with the configure widget operation:

.doit configure -text Stop -command StopIt

The current configuration of a widget can be queried with another form of the configure operation. If you just supply an attribute, the settings associated with that ...

Get Practical Programming in Tcl & Tk, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.