~ubuntu-branches/ubuntu/vivid/gcl/vivid

« back to all changes in this revision

Viewing changes to info/gcl-tk/Common-Features-of-Widgets.html

  • Committer: Package Import Robot
  • Author(s): Camm Maguire
  • Date: 2014-05-16 17:41:33 UTC
  • mto: This revision was merged to the branch mainline in revision 62.
  • Revision ID: package-import@ubuntu.com-20140516174133-czs0uktsjj2vkhxk
2.6.11preĀ testĀ 11

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
 
2
<html>
 
3
<!-- Created by GNU Texinfo 5.2, http://www.gnu.org/software/texinfo/ -->
 
4
<head>
 
5
<title>GCL TK Manual: Common Features of Widgets</title>
 
6
 
 
7
<meta name="description" content="GCL TK Manual: Common Features of Widgets">
 
8
<meta name="keywords" content="GCL TK Manual: Common Features of Widgets">
 
9
<meta name="resource-type" content="document">
 
10
<meta name="distribution" content="global">
 
11
<meta name="Generator" content="makeinfo">
 
12
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
 
13
<link href="index.html#Top" rel="start" title="Top">
 
14
<link href="wm.html#SEC_Contents" rel="contents" title="Table of Contents">
 
15
<link href="General.html#General" rel="up" title="General">
 
16
<link href="Return-Values.html#Return-Values" rel="next" title="Return Values">
 
17
<link href="Getting-Started.html#Getting-Started" rel="prev" title="Getting Started">
 
18
<style type="text/css">
 
19
<!--
 
20
a.summary-letter {text-decoration: none}
 
21
blockquote.smallquotation {font-size: smaller}
 
22
div.display {margin-left: 3.2em}
 
23
div.example {margin-left: 3.2em}
 
24
div.indentedblock {margin-left: 3.2em}
 
25
div.lisp {margin-left: 3.2em}
 
26
div.smalldisplay {margin-left: 3.2em}
 
27
div.smallexample {margin-left: 3.2em}
 
28
div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
 
29
div.smalllisp {margin-left: 3.2em}
 
30
kbd {font-style:oblique}
 
31
pre.display {font-family: inherit}
 
32
pre.format {font-family: inherit}
 
33
pre.menu-comment {font-family: serif}
 
34
pre.menu-preformatted {font-family: serif}
 
35
pre.smalldisplay {font-family: inherit; font-size: smaller}
 
36
pre.smallexample {font-size: smaller}
 
37
pre.smallformat {font-family: inherit; font-size: smaller}
 
38
pre.smalllisp {font-size: smaller}
 
39
span.nocodebreak {white-space:nowrap}
 
40
span.nolinebreak {white-space:nowrap}
 
41
span.roman {font-family:serif; font-weight:normal}
 
42
span.sansserif {font-family:sans-serif; font-weight:normal}
 
43
ul.no-bullet {list-style: none}
 
44
-->
 
45
</style>
 
46
 
 
47
 
 
48
</head>
 
49
 
 
50
<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
 
51
<a name="Common-Features-of-Widgets"></a>
 
52
<div class="header">
 
53
<p>
 
54
Next: <a href="Return-Values.html#Return-Values" accesskey="n" rel="next">Return Values</a>, Previous: <a href="Getting-Started.html#Getting-Started" accesskey="p" rel="prev">Getting Started</a>, Up: <a href="General.html#General" accesskey="u" rel="up">General</a> &nbsp; [<a href="wm.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>]</p>
 
55
</div>
 
56
<hr>
 
57
<a name="Common-Features-of-Widgets-1"></a>
 
58
<h3 class="section">1.3 Common Features of Widgets</h3>
 
59
 
 
60
<p>A <i>widget</i> is a lisp symbol which has a function binding.   The
 
61
first argument is always a keyword and is called the <i>option</i>.
 
62
The argument pattern for the remaining arguments depends on the
 
63
<i>option</i>.    The most common <i>option</i> is <code>:configure</code> in
 
64
which case the remaining arguments are alternating keyword/value
 
65
pairs, with the same keywords being permitted as at the creation
 
66
of the widget.
 
67
</p>
 
68
<p>A <i>widget</i> is created by means of a <i>widget constructor</i>, of
 
69
which there are currently 15, each of them appearing as the title of a
 
70
section in <a href="Widgets.html#Widgets">Widgets</a>.  They live in the <code>&quot;TK&quot;</code> package, and for
 
71
the moment we will assume we have switched to this package.  Thus for
 
72
example <code>button</code> is such a widget constructor function.   Of course
 
73
this is lisp, and you can make your own widget constructors, but when
 
74
you do so it is a good idea to follow the standard argument patterns
 
75
that are outlined in this section.
 
76
</p>
 
77
<div class="example">
 
78
<pre class="example">(button '.hello)
 
79
==&gt; .HELLO
 
80
</pre></div>
 
81
<p>creates a <i>widget</i> whose name is <code>.hello</code>.  There is a parent child
 
82
hierarchy among widgets which is implicit in the name used for the
 
83
widget.   This is much like the pathname structure on a Unix or Dos
 
84
file system, except that <code>'.'</code> is used as the separator rather
 
85
than a <code>/</code> or <code>\</code>.   For this reason the widget instances
 
86
are sometimes referred to as <i>pathnames</i>.   A child of the
 
87
parent widget <code>.hello</code> might be called <code>.hello.joe</code>, and
 
88
a child of this last might be <code>.hello.joe.bar</code>.  The parent of
 
89
everyone is called <code>.</code> .   Multiple top level windows are created
 
90
using the <code>toplevel</code> command (see <a href="toplevel.html#toplevel">toplevel</a>).
 
91
</p>
 
92
<p>The widget constructor functions take keyword and  value  pairs, which
 
93
allow you to specify attributes at the time of creation:
 
94
</p>
 
95
<div class="example">
 
96
<pre class="example">(button '.hello :text &quot;Hello World&quot; :width 20)
 
97
==&gt;.HELLO
 
98
</pre></div>
 
99
<p>indicating that we want the text in the button window to be
 
100
<code>Hello World</code> and the width of the window to be 20 characters
 
101
wide.  Other types of windows allow specification in centimeters
 
102
<code>2c</code>, or in inches (<code>2i</code>) or in millimeters <code>2m</code>
 
103
or in pixels <code>2</code>.   But text windows usually have their
 
104
dimensions specified as multiples of a character width and height.
 
105
This latter concept is called a grid.
 
106
</p>
 
107
<p>Once the window has been created, if you want to change the
 
108
text you do NOT do:
 
109
</p><div class="example">
 
110
<pre class="example">(button '.hello :text &quot;Bye World&quot; :width 20)
 
111
</pre></div>
 
112
<p>This would be in error, because the window .hello already exists.
 
113
You would either have to first call
 
114
</p>
 
115
<div class="example">
 
116
<pre class="example">(destroy '.hello)
 
117
</pre></div>
 
118
 
 
119
<p>But usually you just want to change an attribute.  <code>.hello</code> is
 
120
actually a function, as we mentioned earlier, and it is this function
 
121
that you use:
 
122
</p>
 
123
<div class="example">
 
124
<pre class="example">(.hello :configure :text &quot;Bye World&quot;)
 
125
</pre></div>
 
126
 
 
127
<p>This would simply change the text, and not change where the window had
 
128
been placed on the screen (if it had), or how it had been packed
 
129
into the window hierarchy.   Here the argument <code>:configure</code> is
 
130
called an <i>option</i>, and it specifies which types of keywords can
 
131
follow it.   For example
 
132
</p>
 
133
<div class="example">
 
134
<pre class="example">(.hello :flash)
 
135
</pre></div>
 
136
<p>is also valid, but in this case the <code>:text</code> keyword is not permitted
 
137
after flash.   If it were, then it would mean something else besides
 
138
what it means in the above.  For example one might have defined
 
139
</p>
 
140
<div class="example">
 
141
<pre class="example">(.hello :flash :text &quot;PUSH ME&quot;)
 
142
</pre></div>
 
143
<p>so here the same keyword <code>:text</code> would mean something else, eg
 
144
to flash a subliminal message on the screen.
 
145
</p>
 
146
<p>We often refer to calls to the widget functions 
 
147
as messages.   One reason for this is that they actually turn into
 
148
messages to the graphics process <samp>gcltksrv</samp>.   To actually see these
 
149
messages you can do
 
150
</p><div class="example">
 
151
<pre class="example">(debugging t).
 
152
</pre></div>
 
153
 
 
154
<hr>
 
155
<div class="header">
 
156
<p>
 
157
Next: <a href="Return-Values.html#Return-Values" accesskey="n" rel="next">Return Values</a>, Previous: <a href="Getting-Started.html#Getting-Started" accesskey="p" rel="prev">Getting Started</a>, Up: <a href="General.html#General" accesskey="u" rel="up">General</a> &nbsp; [<a href="wm.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>]</p>
 
158
</div>
 
159
 
 
160
 
 
161
 
 
162
</body>
 
163
</html>