/usr/share/mozart/doc/wp/node21.html is in mozart-doc 1.4.0-8ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>5.2 Checkbuttons, Radiobuttons, and Variables</TITLE><LINK href="ozdoc.css" rel="stylesheet" type="text/css"></HEAD><BODY><TABLE align="center" border="0" cellpadding="6" cellspacing="6" class="nav"><TR bgcolor="#DDDDDD"><TD><A href="node20.html#section.widgets-2.button"><< Prev</A></TD><TD><A href="node19.html">- Up -</A></TD><TD><A href="node22.html#section.widgets-2.return">Next >></A></TD></TR></TABLE><DIV id="section.widgets-2.otherbuttons"><H2><A name="section.widgets-2.otherbuttons">5.2 Checkbuttons, Radiobuttons, and Variables</A></H2><DIV class="apropos"><P class="margin">checkbuttons</P><P> Checkbutton widgets are used for binary choices. An indicator to the left shows whether the button is ``on'' or ``off''. The state of the indicator is given by a tickle variable. A tickle variable is a tickle object that provides messages to set and to query the value of the variable. </P></DIV><DIV class="apropos"><P class="margin">radiobuttons</P><P> Radiobuttons are used for non-binary choices. Several radiobuttons are linked together to a group. Selecting a radio button de-selects all buttons belonging to the same group and displays a mark in an indicator to the left. Radiobuttons are linked together by tickle variables: all buttons belonging to the same group share the same variable. </P></DIV><P> <A href="node21.html#figure.widgets-2.check-and-radio">Figure 5.2</A> shows an example of a checkbutton and a group of three radiobuttons. The value with which the variable <CODE>V1</CODE> is initialized determines whether the checkbutton initially is selected. The value of the variable <CODE>V2</CODE> determines which of the radiobuttons is selected initially. </P><DIV id="figure.widgets-2.check-and-radio"><HR><P><A name="figure.widgets-2.check-and-radio"></A></P><P> </P><DIV align="center"><IMG alt="" src="check-and-radio.gif"></DIV><P> <A name="label209"></A> <A name="label211"></A> <A name="label213"></A> </P><DL class="anonymous"><DD class="code"><CODE>V1={New Tk<SPAN class="keyword">.</SPAN>variable tkInit(<SPAN class="keyword">false</SPAN>)}<BR>C ={New Tk<SPAN class="keyword">.</SPAN>checkbutton tkInit(parent:W variable:V1<BR> text:<SPAN class="string">'Bold'</SPAN> anchor:w)}<BR>V2={New Tk<SPAN class="keyword">.</SPAN>variable tkInit(<SPAN class="string">'Helvetica'</SPAN>)}<BR>Rs={Map [<SPAN class="string">'Times'</SPAN> <SPAN class="string">'Helvetica'</SPAN> <SPAN class="string">'Courier'</SPAN>]<BR> <SPAN class="keyword">fun</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN> F}<BR> {New Tk<SPAN class="keyword">.</SPAN>radiobutton tkInit(parent:W <BR> variable:V2 value:F<BR> text:F anchor:w)}<BR> <SPAN class="keyword">end</SPAN>}<BR>{Tk<SPAN class="keyword">.</SPAN>batch [grid(C padx:2<SPAN class="keyword">#</SPAN>m columnspan:3)<BR> grid(b(Rs) padx:2<SPAN class="keyword">#</SPAN>m)]}</CODE></DD></DL><P> </P><P class="caption"><STRONG>Figure 5.2:</STRONG> A checkbutton and three radiobuttons.</P><HR></DIV><P> </P><DIV class="apropos"><P class="margin">state</P><P> To query the state of the radiobutton and of the checkbuttons we query the state of the corresponding variables. Feeding the following expression </P><DL class="anonymous"><DD class="code"><CODE>{Browse state(bold: {V1 tkReturnInt($)}<SPAN class="keyword">==</SPAN>1<BR> family: {V2 tkReturnAtom($)})}</CODE></DD></DL><P> displays the values of the variables in the browser. See the <A href="node22.html#section.widgets-2.return">next section</A> for a detailed explanation of the <CODE>tkReturnInt</CODE> and <CODE>tkReturnAtom</CODE> messages. </P></DIV><DIV class="apropos"><P class="margin">actions</P><P> Very often selecting a checkbutton or a radiobutton must show immediate effect. For this purpose it is possible to attach actions to checkbuttons and radiobuttons in the same way as for buttons. <A href="node21.html#figure.widgets-2.check-and-radio-action">Figure 5.3</A> shows an example where the checkbutton and the radiobuttons configure the font of a label widget. Note that the options used for initialization of the checkbutton and radiobuttons are the same as in the example shown in <A href="node21.html#figure.widgets-2.check-and-radio">Figure 5.2</A>. </P><DIV id="figure.widgets-2.check-and-radio-action"><HR><P><A name="figure.widgets-2.check-and-radio-action"></A></P><P> </P><DIV align="center"><IMG alt="" src="check-and-radio-action.gif"></DIV><P> <A name="label214"></A> </P><DL class="anonymous"><DD class="code"><CODE><SPAN class="keyword">fun</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">GetWeight</SPAN>}<BR> <SPAN class="keyword">if</SPAN> {V1 tkReturnInt($)}<SPAN class="keyword">==</SPAN>1 <SPAN class="keyword">then</SPAN> bold <SPAN class="keyword">else</SPAN> normal <SPAN class="keyword">end</SPAN> <BR><SPAN class="keyword">end</SPAN> <BR>F={New Tk<SPAN class="keyword">.</SPAN>font tkInit(size:24<BR> family: {V2 tkReturn($)}<BR> weight: {GetWeight})}<BR>L={New Tk<SPAN class="keyword">.</SPAN>label tkInit(parent:W text:<SPAN class="string">'A test text.'</SPAN> font:F)}<BR>{C tkAction(action: <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN>}<BR> {F tk(configure weight:{GetWeight})}<BR> {L tk(configure font:F)}<BR> <SPAN class="keyword">end</SPAN>)}<BR>{List<SPAN class="keyword">.</SPAN>forAllInd [<SPAN class="string">'Times'</SPAN> <SPAN class="string">'Helvetica'</SPAN> <SPAN class="string">'Courier'</SPAN>]<BR> <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN> I Family}<BR> {{Nth Rs I} tkAction(action: <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN>}<BR> {F tk(configure family:Family)}<BR> {L tk(configure font:F)}<BR> <SPAN class="keyword">end</SPAN>)}<BR> <SPAN class="keyword">end</SPAN>}</CODE></DD></DL><P> </P><P class="caption"><STRONG>Figure 5.3:</STRONG> Actions for radiobuttons and checkbuttons.</P><HR></DIV><P> </P></DIV><P> Reference information on radiobuttons and checkbuttons can be found in <A href="../tcltk/TkCmd/radiobutton.htm"><KBD>radiobutton</KBD></A> and <A href="../tcltk/TkCmd/checkbutton.htm"><KBD>checkbutton</KBD></A>. </P></DIV><TABLE align="center" border="0" cellpadding="6" cellspacing="6" class="nav"><TR bgcolor="#DDDDDD"><TD><A href="node20.html#section.widgets-2.button"><< Prev</A></TD><TD><A href="node19.html">- Up -</A></TD><TD><A href="node22.html#section.widgets-2.return">Next >></A></TD></TR></TABLE><HR><ADDRESS><A href="http://www.ps.uni-sb.de/~schulte/">Christian Schulte</A><BR><SPAN class="version">Version 1.4.0 (20110908185330)</SPAN></ADDRESS></BODY></HTML>
|