Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > bd5c3d824c3db63ffd9226c15941e6ad > files > 2359

mozart-1.4.0-1mdv2010.0.i586.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>5.7 Entries and Focus</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="node25.html#section.widgets-2.action">&lt;&lt; Prev</A></TD><TD><A href="node19.html">- Up -</A></TD><TD><A href="node27.html#section.widgets-2.scale">Next &gt;&gt;</A></TD></TR></TABLE><DIV id="section.widgets-2.entry"><H2><A name="section.widgets-2.entry">5.7 Entries and Focus</A></H2><P> An entry widget lets the user enter a single line of text into the widget. An example is shown in <A href="node26.html#figure.widgets-2.entry">Figure&nbsp;5.8</A>. The initialization message for the entry widget specifies the width of the entry in characters. The same holds true for the width of label widgets displaying text: a value for the width without an unit appended is taken as width in characters and not in pixels. </P><DIV id="figure.widgets-2.entry"><HR><P><A name="figure.widgets-2.entry"></A></P><P> </P><DIV align="center"><IMG alt="" src="entry.gif"></DIV><P> <A name="label241"></A> </P><DL class="anonymous"><DD class="code"><CODE>L={New&nbsp;Tk<SPAN class="keyword">.</SPAN>label&nbsp;tkInit(parent:W&nbsp;text:<SPAN class="string">'File&nbsp;name:'</SPAN>)}<BR>E={New&nbsp;Tk<SPAN class="keyword">.</SPAN>entry&nbsp;tkInit(parent:W&nbsp;width:20)}<BR>{Tk<SPAN class="keyword">.</SPAN>batch&nbsp;[pack(L&nbsp;E&nbsp;side:left&nbsp;pady:1<SPAN class="keyword">#</SPAN>m&nbsp;padx:1<SPAN class="keyword">#</SPAN>m)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;focus(E)]}</CODE></DD></DL><P> </P><P class="caption"><STRONG>Figure&nbsp;5.8:</STRONG> An entry widget to enter text.</P><HR></DIV><P> </P><DIV class="apropos"><P class="margin">focus</P><P> To be able to enter text into an entry, the entry needs to have the <A name="label242"></A><EM>focus</EM>. If a widget has the focus, all input from the keyboard is directed to that widget. A widget that has the focus is drawn with a frame around it. To give the focus to widget, we can use the <CODE>focus</CODE> command as in the above example. </P></DIV><P> An entry widget can be given the focus also by clicking it with the mouse button. It is also possible to give the focus to button widgets. That allows to invoke actions with keys, and to move the focus between several widgets by pressing keys. For more on this, see <A href="../tcltk/TkCmd/focus.htm"><KBD>focus</KBD></A>. </P><DIV class="apropos"><P class="margin">returning entered text</P><P> To query the string entered in a widget the command <CODE>get</CODE> is provided. To display the entered string in the Browser we can execute </P><DL class="anonymous"><DD class="code"><CODE>{Browse&nbsp;{E&nbsp;tkReturnAtom(get&nbsp;$)}}</CODE></DD></DL><P> </P></DIV><P> The string entered in an entry can be deleted, additional characters can be inserted, and so on. More on entry widgets you can find in <A href="../tcltk/TkCmd/entry.htm"><KBD>entry</KBD></A>. </P></DIV><TABLE align="center" border="0" cellpadding="6" cellspacing="6" class="nav"><TR bgcolor="#DDDDDD"><TD><A href="node25.html#section.widgets-2.action">&lt;&lt; Prev</A></TD><TD><A href="node19.html">- Up -</A></TD><TD><A href="node27.html#section.widgets-2.scale">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 (20090610)</SPAN></ADDRESS></BODY></HTML>