Tcl-Tk-Tkwidget-Tix
view release on metacpan or search on metacpan
docs/tix-book/intro.tex.html view on Meta::CPAN
option add *a.b.megaw.subw.option1 value1
option add *a.b.megaw.subw.option2 value2
</pre></blockquote>
because in general we will not know whether the subwidget is an
immediate child window of <code> .a.b.megaw</code> (<i>such a decision
is left to the mega-widget implementor and may vary in different
versions of the same mega-widget</i>).
<p> Program <a href=intro.tex.html#1-7>1-7 </a> demonstrates how the Tk Option
Database can be used to achieve the same effect as program
<a href=intro.tex.html#1-5>1-5 </a>.
<p><blockquote><a name=1-7>
<blockquote><pre>
option add *TixControl*label.width 8
option add *TixControl*label.anchor e
option add *TixControl*entry.width 10
option add *TixControl*entry.borderWidth 3
<p>tixControl .income -label "Income: " -variable income
tixControl .age -label "Age: " -variable age
<p>pack .income .age -side top
</pre></blockquote>
<hr><center><h3>(Figure 1-7) Using the Tk Option Database in Place of the <code> -options</code>
switch</center></h3>
</blockquote>
<p><H3><A NAME=1.3.7>1.3.7 Caution: Restricted Access</H3>
<p> In the current implementation of Tix, there is no limits on how you
can access the options of the subwidgets. However, many options of
the subwidgets may be already used by the mega-widget in special
ways. For example, the <code> -textvariable</code> option of the <code> entry</code>
subwidget of TixControl may be used to store some private
information for the mega widget. Therefore, you should access the
options of the subwidgets with great care. In general you should
only access those options that affect the appearance of the
subwidgets (such as <code> -font</code> or <code> -foreground</code>) and leave
everything else intact. (<i></i>) { In future versions of Tix, there
will be explicit restrictions on which subwidget options you can
access. Errors will be generated if you try to access restricted
subwidget options}
<p>
<p><H2><A NAME=1.4>1.4 Another Tix Widget: TixComboBox</H2>
<p> The <i> TixComboBox</i> widget is very similar to the ComboBox widgets
available in MS Windows and Motif 2.0. A TixComboBox consists of an
entry widget and a listbox widget. Usually, the ComboBox contains a
list of possible values for the user to select. The user may also
choose an alternative value by typing it in the entry widget. Figure
<a href=intro.tex.html#1-8>1-8 </a> shows two ComboBoxes for the user to choose fonts and
character sizes. You can see fro the figure that a listbox is popped
down from the ComboBox for fonts for the user to choose among a list
of possible fonts.
<p>
<blockquote><a name=1-8>
<center><img src=fig/intro/combobox.gif></center>
<hr><center><h3>(Figure 1-8) The TixComboBox Widget</center></h3>
</blockquote>
<p><H3><A NAME=1.4.1>1.4.1 Creating a TixComboBox Widget</H3>
<p><blockquote><a name=1-9>
<blockquote><pre>
tixComboBox .c -label "Animal:" -editable true
.c insert end cat
.c insert end dog
.c insert end pig
</pre></blockquote>
<hr><center><h3>(Figure 1-9) Creating a ComboBox</center></h3>
</blockquote>
<p> In program <a href=intro.tex.html#1-9>1-9 </a>, we set up a ComboBox <code> .c</code>
for the user to select an animal to play with. If the user is just a
dull person like you and me, he would just press the arrow button
and select a pre-designated animal such as ``dog''. However, if he
wants to try something new, he could type ``micky'' or ``sloth''
into the entry widget and he will get to play with his favorite
animal.
<p> Of course, sometimes we don't want too many sloths around us and we
want to limit the range of the user's selections. In this case we
can do one of two things. First, we can set the <code> -editable</code>
option to <code> false</code> so that the user cannot type in the entry
widget at all. Alternatively, we can use the <code> -validatecmd</code>
option (see section <a href=intro.tex.html#1.4.3>1.4.3 </a>) to check input the input.
<p><H3><A NAME=1.4.2>1.4.2 Controlling the Style of the TixComboBox</H3>
<p> The TixComboBox widget can appear in many different styles. If we
set the <code> -dropdown</code> option to <code> true</code> (which is the default),
the listbox will only appear when the user presses the arrow button.
When <code> -dropdown</code> is set to <code> false</code>, the listbox is always
shown and the arrow button will disappear because it is not needed
anymore.
<p> There is also an option called <code> -fancy</code>. It is set to <code>
false</code> by default. When set to <code> true</code>, a tick button and a cross
button will appear next to the entry widget. The tick button allows
you to select again the value that's already in the ComboBox. If you
press the cross button, the entry widget will be cleared.
<p><H3><A NAME=1.4.3>1.4.3 Static Options</H3>
<p> The <code> -dropdown</code> and <code> -fancy</code> options are so-called ``static
options''. They can only be set during the creation of the
ComboBox. Hence this code is valid:
<p><pre>
tixComboBox .c -dropdown true
</pre>
<p> But the following code will generate an error because it attempts to
set the <code> -dropdown</code> option <i> after</i> the ComboBox has already
been created.
<p><pre>
( run in 0.652 second using v1.01-cache-2.11-cpan-2398b32b56e )