Creating a TixControl Widget<A NAME=121> </A>

Next: Accessing The Value Up: Getting Started: the Previous: Getting Started: the

### Creating a TixControl Widget

The following code demonstrates how to create a TixControl widget and specify its options:

`tixControl .lawyers -label Lawyers: -max 10 -min 0
.lawyers config -integer true -step 2`

This example creates a TixControl widget that let us to select the numbers of lawyers we wish to be allowed in this country. (Figure 1-2)

Let us examine the options: the `-label` option specifies a caption for this widget. The `-max` option specifies the maximum number of lawyers we can choose. The `-min` option specifies the minimum number of lawyers we can choose: although we would love to enter a negative number, reality dictate that the lower limit must be zero. The `-integer` option indicates that the number of lawyers must be an integer; that is, we respect the lawyers' rights not to be chopped up into decimal points. Finally, since lawyers seem to go in pairs, we set the `-step` option to `2`, which indicates that when we press the up/down arrow buttons, we want the number of lawyers to go up and down by two each time.

As shown in the example, you can create and manipulate a Tix widget in the same manner as the standard Tk widgets. The options of the widget can be specified during the creation of the widget. Alternatively, they can be changed by the `configure` widget command. In addition, options can also be specified in the option database or as X resources. Here is an example that produces the same result as the previous code fragment:

`option add *lawyers.max 10
option add *lawyers.min 0
tixControl .lawyers -label Lawyers: -integer true
.lawyers config -step 2`

In figure 1-3, you can see the composition of TixControl: it is made out of a label widget, an entry widget and two button widgets. Widgets that are composed of other widgets, like TixControl, are called mega-widgets. Most widgets in the Tix library are mega-widgets (xx: and as you know this book is about them!).