The TopLevelWidget Itcl class is a subclass of itk::Toplevel and thus inherits all of the features described in Toplevel(n) . In addition, a number of useful methods are defined, for use by the derived classes. These include support for adding a menubar, menu buttons and menu items to the top of the window and adding a short help window at the bottom. A short help text is defined for each menu item and widget and it is displayed (in the short help window) whenever the mouse passes over it.
Both the FrameWidget and TopLevelWidget classes call the init method when all the constructors have completed (using the after idle command). The init method is often the best place to build widgets, since at that point you know the values of all of the Itcl options.
Any subclass of TopLevelWidget automatically has support for a user defined plugin . For any class named Foo , for example, a Tcl proc named Foo_plugin many be defined. The plugin proc is called after the class construction is complete (after calling init ) with the name of the class instance. If the environment variable FOO_PLUGIN is defined (replace FOO with the class name in upper case), it is assumed to be the name of the Tcl source file containing the plugin code and defining the Tcl proc Foo_plugin . The file is sourced and the file's directory is added to the Tcl auto_path variable.
This plugin feature can be used to add features to widgets, such as additional menus or buttons. Once you have the handle for the top level widget, it is usually easy to access other internal widgets, if necessary, to make any changes or additions you want. The Tcl language is also very flexible and will allow you to redefine procedures and methods at run time.
The normal way to use the TopLevelWidget class is to declare it as a base class:
inherit TopLevelWidget
However, you could also create an instance directly, for example:
TopLevelWidget .t .t add_menubar .t add_menubutton File .t add_menubutton View .t add_menubutton Edit .t make_short_help
See TopLevelWidget(n) for more details.
Please send questions or comments to abrighto@eso.org.
Copyright © 1998 ESO - European Southern Observatory