Next: Disabling Callbacks Temporarily Up: Getting Started: the Previous: Creating a TixControl

 

Accessing The Value of a TixControl Widget 

The TixControl widget allows the user to input a value. There are several ways to read this value in your program. First of all, TixControl stores the current value in the -value option. You can use query the -value option by calling the command

.c cget -value this command will return the current value of the tixContro widget .c. The following command sets the value of the widget to a new number (100):

.c config -value 100

The second way to access the value of TixControl is to use the -variable option. This options instructs the TixControl widget to store the its value into a global variable so that you can read it at any time. Also, by assigning a new value to this global variable, you can change the value of the TixControl widget. Here is an example:

.c config -variable myvar
set myvar 100

In some situations, you may want to be informed immediately when the value of the TixControl widget changes. To accomplish this, you can use the -command option. The following line causes the TCL procedure valueChanged to be called whenever the value of .c changes:

tixControl .c -command valueChanged


http://tix.sourceforge.net