Next | Prev | Up | Top | Contents | Index

Widget Basics

Motif uses a hierarchy of subwindows to create and organize interface elements such as menu items, push buttons, or data entry fields. In Motif and Xt jargon, these are called widgets. Widgets are organized in a hierarchy, with the application itself forming the root (or top) of the hierarchy.

Programming a graphical user interface consists of the following steps:

  1. Create all the widgets you need, in a suitable hierarchy.

  2. Configure widget color, size, alignment, and fonts.

    In Motif, widgets are configured based on resources, which may be set for all widgets in a class or on a per-widget basis. For example, one push button could have a red background, or all push buttons could have a red background. Motif also provides inheritance between widget classes: push buttons have a background color resource because they inherit this resource (but not its setting) from Label.

  3. Program your interface to react when users supply input. For example, a function should be called when the PushMe button is clicked. This functions is a callback associated with the widget. A callback is a fragment of Tcl code executed when some event occurs. Here is an example callback for the PushMe button:

    {puts stdout "Hello World"}


Widget Names
Creating a Widget
Widget Methods
Widget Resources
Actions and Callbacks
Translations
Widget Creation Commands
The Root Widget

Next | Prev | Up | Top | Contents | Index