/usr/share/mozart/doc/wp/node22.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.3 Querying Tickle Objects</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="node21.html#section.widgets-2.otherbuttons"><< Prev</A></TD><TD><A href="node19.html">- Up -</A></TD><TD><A href="node23.html#section.widgets-2.menu">Next >></A></TD></TR></TABLE><DIV id="section.widgets-2.return"><H2><A name="section.widgets-2.return">5.3 Querying Tickle Objects</A></H2><P> In the previous section we queried a Tk-variable's state with the methods <CODE>tkReturnInt</CODE> and <CODE>tkReturnAtom</CODE>. In fact it is possible to query the state of all tickle objects, in particular to query the state of widgets. </P><P> All tickle objects provide a method <CODE>tkReturn</CODE>. This method is similar to the <CODE>tk</CODE> method in that it sends a message to the graphics engine. After the message has been executed by the graphics engine, however, the <CODE>tkReturn</CODE> method returns a string, whereas the <CODE>tk</CODE> method ignores this string. </P><DIV class="apropos"><P class="margin">synchronization</P><P> The field of the <CODE>tkReturn</CODE> message with the largest integer feature is constrained to the string returned. The method <CODE>tkReturn</CODE> is asynchronous: it sends the message to the graphics engine but does not block the thread until the return string is available. Eventually the graphics engine writes the return string to the store. </P></DIV><P> The <CODE>tkReturn</CODE> message is sent asynchronously for efficiency reasons. One can start another calculation without having to wait for <CODE>tkReturn</CODE>'s result. One can send several <CODE>tkReturn</CODE> messages consecutively, and they will be sent immediately. The messages will be handled by the graphics agent in the same order as they are sent. </P><P> If you want to be sure that you have received the return value, say <CODE>X</CODE>, of <CODE>tkReturn</CODE> before continuing, then you must use a <CODE>{Wait X}</CODE> statement. </P><DIV class="apropos"><P class="margin">illegal return values</P><P> Similar to the method <CODE>tkReturn</CODE> tickle objects provide methods that return atoms, integers, floats and lists of strings, atoms, integers, and floats. Rather than writing a string to the store they write a value to the store which is obtained by transforming the string to the particular type. If it is not possible to transform the string into a value of that type, the boolean value <CODE><SPAN class="keyword">false</SPAN></CODE> is written to the store. </P></DIV><P> The methods that return a list of strings, atoms, integers, or floats split the string into substrings separated by space characters. For instance, the return string <CODE><SPAN class="string">"a b c"</SPAN></CODE> is transformed into the list <CODE>[a b c]</CODE> by the method <CODE>tkReturnListAtom</CODE>. <A href="node22.html#table.widgets-2.return">Table 5.1</A> lists the return methods and how the methods transform strings. Note that a string <CODE><SPAN class="string">"1.0"</SPAN></CODE> is transformed by <CODE>tkReturnInt</CODE> to the integer <CODE>1</CODE>. </P><DIV class="table" id="table.widgets-2.return"><HR><P><A name="table.widgets-2.return"></A></P></DIV><TABLE align="center" bgcolor="#f0f0e0"><TR valign="top"><TH><P>Method </P></TH><TH><P>Example string </P></TH><TH><P>Return value </P></TH></TR><TR valign="top"><TD><P><CODE>tkReturn</CODE> </P></TD><TD><P><CODE><SPAN class="string">"red 1 1.0"</SPAN></CODE> </P></TD><TD><P><CODE><SPAN class="string">"red 1 1.0"</SPAN></CODE> </P></TD></TR><TR valign="top"><TD><P><CODE>tkReturnAtom</CODE> </P></TD><TD><P><CODE><SPAN class="string">"red 1 1.0"</SPAN></CODE> </P></TD><TD><P><CODE><SPAN class="string">'red 1 1.0'</SPAN></CODE> </P></TD></TR><TR valign="top"><TD><P><CODE>tkReturnInt</CODE> </P></TD><TD><P><CODE><SPAN class="string">"1"</SPAN></CODE> </P></TD><TD><P><CODE>1</CODE> </P></TD></TR><TR valign="top"><TD><P><CODE>tkReturnFloat</CODE> </P></TD><TD><P><CODE><SPAN class="string">"1.0"</SPAN></CODE> </P></TD><TD><P><CODE>1<SPAN class="keyword">.</SPAN>0</CODE> </P></TD></TR><TR valign="top"><TD><P><CODE>tkReturnList</CODE> </P></TD><TD><P><CODE><SPAN class="string">"red 1 1.0"</SPAN></CODE> </P></TD><TD><P><CODE>[<SPAN class="string">"red"</SPAN> <SPAN class="string">"1"</SPAN> <SPAN class="string">"1.0"</SPAN>]</CODE> </P></TD></TR><TR valign="top"><TD><P><CODE>tkReturnListAtom</CODE> </P></TD><TD><P><CODE><SPAN class="string">"red 1 1.0"</SPAN></CODE> </P></TD><TD><P><CODE>[red <SPAN class="string">'1'</SPAN> <SPAN class="string">'1.0'</SPAN>]</CODE> </P></TD></TR><TR valign="top"><TD><P><CODE>tkReturnListInt</CODE> </P></TD><TD><P><CODE><SPAN class="string">"red 1 1.0"</SPAN></CODE> </P></TD><TD><P><CODE>[<SPAN class="keyword">false</SPAN> 1 1]</CODE> </P></TD></TR><TR valign="top"><TD><P><CODE>tkReturnListFloat</CODE> </P></TD><TD><P><CODE><SPAN class="string">"red 1 1.0"</SPAN></CODE> </P></TD><TD><P><CODE>[<SPAN class="keyword">false</SPAN> 1<SPAN class="keyword">.</SPAN>0 1<SPAN class="keyword">.</SPAN>0]</CODE> </P></TD></TR></TABLE><DIV class="table"><P class="caption"><STRONG>Table 5.1:</STRONG> Returns methods and examples of return values.</P><HR></DIV><P> </P><DIV class="apropos"><P class="margin">string handling procedures</P><P> The Tk Module provides also for a set of procedures that can transform strings into atoms, integers, floats and lists of these three types. With these procedures it is possible to transform return strings in a user defined fashion. For more information see <A href="../system/node93.html#section.tk.strings">Section 28.12 of ``System Modules''</A>. </P></DIV><H3><A name="label215">5.3.1 Querying Configuration Options</A></H3><P> The values of configuration options of a widget can be queried with the <CODE>configure</CODE> command. Instead of giving a value to which the option is to be set, we give the tickle <CODE><SPAN class="keyword">unit</SPAN></CODE> as value. The tickle <CODE><SPAN class="keyword">unit</SPAN></CODE> expands to just nothing, meaning that the value is not to be set but to be queried. For example, to query the value of the <CODE>bg</CODE> option of a widget <CODE><I>T</I></CODE>, we can feed </P><BLOCKQUOTE class="code"><CODE>{</CODE><CODE><I>T</I></CODE><CODE> tkReturnListAtom(configure bg:<SPAN class="keyword">unit</SPAN> $)}</CODE></BLOCKQUOTE><P> </P><P> This displays a list of atoms, usually it suffices to know that the current value of the option is the fifth element of the list, whereas its default value is the fourth element of the list. </P><H3><A name="label216">5.3.2 Querying Widget Parameters</A></H3><P> The command <CODE>winfo</CODE> is helpful to query parameters of widgets. For instance, to query the position and geometry of a widget <CODE><I>T</I></CODE>, we can use the following: <A name="label218"></A> </P><BLOCKQUOTE class="code"><CODE>{Browse {Map [rootx width rooty height]<BR> <SPAN class="keyword">fun</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN> A} <BR> {Tk<SPAN class="keyword">.</SPAN>returnInt winfo(A </CODE><CODE><I>T</I></CODE><CODE>)} <BR> <SPAN class="keyword">end</SPAN>}}</CODE></BLOCKQUOTE><P> The <CODE>winfo</CODE> command provides more options than those used above, for the details please consult <A href="../tcltk/TkCmd/winfo.htm"><KBD>winfo</KBD></A>. </P></DIV><TABLE align="center" border="0" cellpadding="6" cellspacing="6" class="nav"><TR bgcolor="#DDDDDD"><TD><A href="node21.html#section.widgets-2.otherbuttons"><< Prev</A></TD><TD><A href="node19.html">- Up -</A></TD><TD><A href="node23.html#section.widgets-2.menu">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>
|