2.9.6. Toolkit API
Widget properties can push and pull information to the user interface. Widgets have properties specific to their type. For example, when you click a button, the button property onClick performs an action. A label widget does not have the same property, because the widget does not perform an action on click operation. However, both the button and label widgets have the text property to display text strings.
The Toolkit API service creates a widget hierarchy where the toolkit is at the top-level. The service implements group-type widgets that contain child widgets. Layout properties dictate layout actions that a parent performs on its children. For example, the expandableX property when set as True, expands the widget horizontally to encompass all of the available space. The visible property when set as True allows a widget to display in the GUI.
Some widgets allow user interaction. For example, the textField widget is a text box that allows user entries. Access the contents of the box with the text property. A Tcl script can either get or set the contents of the textField widget with the text property.
Some widgets perform user-specified actions, referred to as callbacks. The textField widget has the onChange property, which is called when text contents change. The button widget has the onClick property, which is called when you click a button. Callbacks update widgets or interact with services based on the contents of a text field, or the state of any other widget.
Did you find the information on this page useful?