Next: Specifying Selection Rules Up: The TixSelect Widget Previous: Creating the Button


Accessing the Button Subwidgets 

We have already seen the concept of subwidgets and how they can be accessed in section 1.3.1 - when we create a Tix mega-widget, some subwidgets are created for us automatically. For example, the label and entry subwidgets inside a TixControl widget. We can access these subwidgets in a multitude of ways, including using the subwidget method.

One thing about the subwidgets we saw in section 1.3.1 is that they are ``static'', meaning they are created when the mega-widget is created and they remain there for the whole lifetime of the mega-widget.

The TixSelect widget takes us to a new concept: dynamic subwidgets are subwidgets that can be created on-the-fly. After we add a new button into the TixSelect widget, we get a new subwidget. The name of this new subwidget is given by the first parameter passed to the add method. As the following code demonstrates, we can access this new subwidget using the subwidget method:

tixSelect .s
.s add apple -text Apple
.s add orange -text Orange
# Mmmm..., let's make the widget look more educated
# by using French words
.s subwidget apple config -text Pomme
.s subwidget orange config -text Orange