Next: Accessing the Value Up: The TixSelect Widget Previous: Accessing the Button


Specifying Selection Rules 

For simple selection rules, you can use the -allowzero and -radio options. The -allowzero option specifies whether the user can select none of the choices inside the TixSelect widget. The -radio option controls how many buttons can be selected at once: when set to true, the user can select only one button at a time; when set to false, the user can select as many buttons as he desires.

With these two options, we can write a program using two TixSelect widgets for little Jimmy to fill up his lunch box. On the Sandwich side, we set -radio to true and -allowzero false. That means Jimmy can select one and only one sandwich among beef, cheese or ham sandwiches. On the Veggie side, we want to encourage Jimmy to consume as much veggie as possible, so we set the -allowzero option to false. We also set the -allowzero option to false so that Jimmy cannot get away with eating none of the vegetables (see program 1-13).

tixSelect .sandwich -allowzero false -radio true -label "Sandwich :"
.sandwich add beef -text Beef
.sandwich add cheese -text Cheese
.sandwich add ham -text Ham

tixSelect .vege -allowzero false -radio false -label "Vegetable :"
.vege add bean -text Bean
.vege add carrot -text Carrot
.vege add lettuce -text Lettuce

(Figure 1-13) Specifying Simple Selection Rules