This file is indexed.

/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">&lt;&lt; Prev</A></TD><TD><A href="node19.html">- Up -</A></TD><TD><A href="node22.html#section.widgets-2.return">Next &gt;&gt;</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&nbsp;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&nbsp;Tk<SPAN class="keyword">.</SPAN>variable&nbsp;tkInit(<SPAN class="keyword">false</SPAN>)}<BR>C&nbsp;={New&nbsp;Tk<SPAN class="keyword">.</SPAN>checkbutton&nbsp;tkInit(parent:W&nbsp;variable:V1<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;text:<SPAN class="string">'Bold'</SPAN>&nbsp;anchor:w)}<BR>V2={New&nbsp;Tk<SPAN class="keyword">.</SPAN>variable&nbsp;tkInit(<SPAN class="string">'Helvetica'</SPAN>)}<BR>Rs={Map&nbsp;[<SPAN class="string">'Times'</SPAN>&nbsp;<SPAN class="string">'Helvetica'</SPAN>&nbsp;<SPAN class="string">'Courier'</SPAN>]<BR>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN class="keyword">fun</SPAN><SPAN class="variablename">&nbsp;</SPAN>{<SPAN class="functionname">$</SPAN>&nbsp;F}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{New&nbsp;Tk<SPAN class="keyword">.</SPAN>radiobutton&nbsp;tkInit(parent:W&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;variable:V2&nbsp;value:F<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;text:F&nbsp;anchor:w)}<BR>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN class="keyword">end</SPAN>}<BR>{Tk<SPAN class="keyword">.</SPAN>batch&nbsp;[grid(C&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;padx:2<SPAN class="keyword">#</SPAN>m&nbsp;columnspan:3)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;grid(b(Rs)&nbsp;padx:2<SPAN class="keyword">#</SPAN>m)]}</CODE></DD></DL><P> </P><P class="caption"><STRONG>Figure&nbsp;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&nbsp;state(bold:&nbsp;&nbsp;&nbsp;{V1&nbsp;tkReturnInt($)}<SPAN class="keyword">==</SPAN>1<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;family:&nbsp;{V2&nbsp;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&nbsp;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&nbsp;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">&nbsp;</SPAN>{<SPAN class="functionname">GetWeight</SPAN>}<BR>&nbsp;&nbsp;&nbsp;<SPAN class="keyword">if</SPAN>&nbsp;{V1&nbsp;tkReturnInt($)}<SPAN class="keyword">==</SPAN>1&nbsp;<SPAN class="keyword">then</SPAN>&nbsp;bold&nbsp;<SPAN class="keyword">else</SPAN>&nbsp;normal&nbsp;<SPAN class="keyword">end</SPAN>&nbsp;<BR><SPAN class="keyword">end</SPAN>&nbsp;<BR>F={New&nbsp;Tk<SPAN class="keyword">.</SPAN>font&nbsp;tkInit(size:24<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;family:&nbsp;{V2&nbsp;tkReturn($)}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;weight:&nbsp;{GetWeight})}<BR>L={New&nbsp;Tk<SPAN class="keyword">.</SPAN>label&nbsp;tkInit(parent:W&nbsp;text:<SPAN class="string">'A&nbsp;test&nbsp;text.'</SPAN>&nbsp;font:F)}<BR>{C&nbsp;&nbsp;tkAction(action:&nbsp;<SPAN class="keyword">proc</SPAN><SPAN class="variablename">&nbsp;</SPAN>{<SPAN class="functionname">$</SPAN>}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{F&nbsp;tk(configure&nbsp;weight:{GetWeight})}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{L&nbsp;tk(configure&nbsp;font:F)}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN class="keyword">end</SPAN>)}<BR>{List<SPAN class="keyword">.</SPAN>forAllInd&nbsp;[<SPAN class="string">'Times'</SPAN>&nbsp;<SPAN class="string">'Helvetica'</SPAN>&nbsp;<SPAN class="string">'Courier'</SPAN>]<BR>&nbsp;<SPAN class="keyword">proc</SPAN><SPAN class="variablename">&nbsp;</SPAN>{<SPAN class="functionname">$</SPAN>&nbsp;I&nbsp;Family}<BR>&nbsp;&nbsp;&nbsp;&nbsp;{{Nth&nbsp;Rs&nbsp;I}&nbsp;tkAction(action:&nbsp;<SPAN class="keyword">proc</SPAN><SPAN class="variablename">&nbsp;</SPAN>{<SPAN class="functionname">$</SPAN>}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{F&nbsp;tk(configure&nbsp;family:Family)}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{L&nbsp;tk(configure&nbsp;font:F)}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN class="keyword">end</SPAN>)}<BR>&nbsp;<SPAN class="keyword">end</SPAN>}</CODE></DD></DL><P> </P><P class="caption"><STRONG>Figure&nbsp;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">&lt;&lt; Prev</A></TD><TD><A href="node19.html">- Up -</A></TD><TD><A href="node22.html#section.widgets-2.return">Next &gt;&gt;</A></TD></TR></TABLE><HR><ADDRESS><A href="http://www.ps.uni-sb.de/~schulte/">Christian&nbsp;Schulte</A><BR><SPAN class="version">Version 1.4.0 (20110908185330)</SPAN></ADDRESS></BODY></HTML>