Each widget instance is composed of three integral parts: variables, methods and component widgets.
Each variable can be public or private. Public variables may be
accessed by the application programmer (usually via
cget methods) and their names usually start with a dash (-).
They usually are used to represent some user-configurable options of
the widget instance. Private variables, on the other hand, cannot be
accessed by the application programmer. They are usually used to store
information about the widget instance that are of interest only to the
All the variables of an instance are stored in a global array
(dictionary) that has the same name as the instance. For example, the
variables of the instance
.up are stored in the global array
.up. The public variable
-direction, which records the
direction to which the arrow is pointing to, is stored in
.up(-direction). The private variable
counts how many times the user has pressed the button, is stored in
.up(count). In comparison, the same variables of the
instance are stored in
TixArrowButtonclass supports the public methods
invokeand invert, the application programmer can issue the commands to call these method for the widget instance
.up invert .up invokeIn contrast, private methods are of interests only to widget writers and cannot be called by application programmers.
The root widget has the same name as the mega-widget itself. In
the above example, we have a mega-widget called
.up. It has a
root widget which is a frame widget and is also called
.up we have a button subwidget called
Similar to variables and methods, component widgets are also
classified into public and private component widgets. Only public
widgets may be accessed by the application programmer, via the
subwidget method of each widget instance.