16.1.3 A (Very) Quick Look at Tcl/Tk



To make use of this reference material, there will be times when you will need to know how to read short passages of Tk and how to identify the various parts of a Tk command. (See section 16.1.4 for the Tkinter equivalents of what's below.)



                classCommand newPathname options



configure the widget's appearance and in some cases, its behavior. The options come in the form of a list of flags and values. Flags are proceeded by a `-', like unix shell command flags, and values are put in quotes if they are more than one word.

For example:

    button   .fred   -fg red -text "hi there"
       ^       ^     \_____________________/
       |       |                |
     class    new            options

Once created, the pathname to the widget becomes a new command. This new widget command is the programmer's handle for getting the new widget to perform some action. In C, you'd express this as someAction(fred, someOptions), in C++, you would express this as fred.someAction(someOptions), and in Tk, you say:

    .fred someAction someOptions


As you'd expect, the legal values for someAction will depend on the widget's class: .fred disable works if fred is a button (fred gets greyed out), but does not work if fred is a label (disabling of labels is not supported in Tk).

The legal values of someOptions is action dependent. Some actions, like disable, require no arguments, others, like a text-entry box's delete command, would need arguments to specify what range of text to delete.
