4 <meta name="description" content="Pmw - a toolkit for building high-level compound widgets in Python">
5 <meta name="content" content="python, megawidget, mega widget, compound widget, gui, tkinter">
6 <title>Pmw.TimeCounter reference manual</title>
9 <body bgcolor="#ffffff" text="#000000" link="#0000ee"
10 vlink="551a8b" alink="ff0000">
12 <h1 ALIGN="CENTER">Pmw.TimeCounter</h1>
14 <center><IMG SRC=TimeCounter.gif ALT="" WIDTH=170 HEIGHT=85></center>
16 <dt> <h3>Name</h3></dt><dd>
17 <p>Pmw.TimeCounter() -
18 counter for display and input of time
23 <dt> <h3>Inherits</h3></dt><dd>
24 <a href="MegaWidget.html">Pmw.MegaWidget</a><br>
26 <dt> <h3>Description</h3></dt><dd>
28 A time counter is similar to a regular <a href="Counter.html">Pmw.Counter</a> except that the
29 user may increment and decrement the hours, minutes and seconds
36 <dt> <h3>Options</h3></dt><dd>
37 Options for this megawidget and its base
38 classes are described below.<p></p>
39 <a name=option.autorepeat></a>
40 <dl><dt> <strong>autorepeat
42 If true, the counter will continue to count up or down while an
43 arrow button is held pressed down. The default is <strong>1</strong>.</p>
47 <a name=option.buttonaspect></a>
48 <dl><dt> <strong>buttonaspect
50 Initialisation option. Specifies the width of the arrow buttons as a proportion of their
51 height. Values less than <strong>1.0</strong> will produce thin arrow buttons.
52 Values greater than <strong>1.0</strong> will produce fat arrow buttons. The default is <strong>1.0</strong>.</p>
56 <a name=option.command></a>
57 <dl><dt> <strong>command
59 This specifies a function to call whenever the <strong><Return></strong> key is
60 pressed in one of the entry fields or <code>invoke()</code> is called. The default is <strong>None</strong>.</p>
64 <a name=option.initwait></a>
65 <dl><dt> <strong>initwait
67 Specifies the initial delay (in milliseconds) before a depressed
68 arrow button automatically starts to repeat counting. The default is <strong>300</strong>.</p>
72 <a name=option.labelmargin></a>
73 <dl><dt> <strong>labelmargin
75 Initialisation option. If the <strong>labelpos</strong> option is not <strong>None</strong>, this specifies the
76 distance between the <strong>label</strong> component and the rest of the
77 megawidget. The default is <strong>0</strong>.</p>
81 <a name=option.labelpos></a>
82 <dl><dt> <strong>labelpos
84 Initialisation option. Specifies where to place the <strong>label</strong> component. If not
85 <strong>None</strong>, it should be a concatenation of one or two of the
86 letters <strong>'n'</strong>, <strong>'s'</strong>, <strong>'e'</strong> and <strong>'w'</strong>. The first letter
87 specifies on which side of the megawidget to place the label.
88 If a second letter is specified, it indicates where on that
89 side to place the label. For example, if <strong>labelpos</strong> is <strong>'w'</strong>,
90 the label is placed in the center of the left hand side; if
91 it is <strong>'wn'</strong>, the label is placed at the top of the left
92 hand side; if it is <strong>'ws'</strong>, the label is placed at the
93 bottom of the left hand side.</p>
94 <p> If <strong>None</strong>, a label component is not created. The default is <strong>None</strong>.</p>
99 <a name=option.max></a>
102 Specifies the maximum acceptable time in the form "HH:MM:SS", or
103 <strong>None</strong> if no maximum checking should be performed. The default is <strong>None</strong>.</p>
107 <a name=option.min></a>
110 Specifies the minimum acceptable time in the form "HH:MM:SS", or
111 <strong>None</strong> if no minimum checking should be performed. The default is <strong>None</strong>.</p>
115 <a name=option.padx></a>
116 <dl><dt> <strong>padx
118 Initialisation option. Specifies how much wider to make each column than the default
119 width (where a column consists of two arrows and an entry field).
120 The entry fields expand to fill the extra space, but the arrow
121 buttons are centered in the available space. The default is <strong>0</strong>.</p>
125 <a name=option.pady></a>
126 <dl><dt> <strong>pady
128 Initialisation option. Specifies how much higher to make each row of arrow buttons than
129 the default hight. The arrow buttons are centered in the
130 available space. The default is <strong>0</strong>.</p>
134 <a name=option.repeatrate></a>
135 <dl><dt> <strong>repeatrate
137 Specifies the delay (in milliseconds) between automatic counts
138 while an arrow button is held pressed down. The default is <strong>50</strong>.</p>
142 <a name=option.value></a>
143 <dl><dt> <strong>value
145 Initialisation option. Specifies the initial contents of the time counter, in the form
146 "HH:MM:SS". If this is <strong>None</strong>, the current time is used as the
147 initial contents. The default is <strong>None</strong>.</p>
152 <dt> <h3>Components</h3></dt><dd>
153 Components created by this megawidget and its base
154 classes are described below.<p></p>
155 <a name=component.downhourarrow></a>
156 <dl><dt> <strong>downhourarrow
158 The arrow button used for decrementing the hour field. By default, this component is a Tkinter.Canvas. Its component group is <strong>Arrow</strong>.</p>
162 <a name=component.downminutearrow></a>
163 <dl><dt> <strong>downminutearrow
165 The arrow button used for decrementing the minute field. By default, this component is a Tkinter.Canvas. Its component group is <strong>Arrow</strong>.</p>
169 <a name=component.downsecondarrow></a>
170 <dl><dt> <strong>downsecondarrow
172 The arrow button used for decrementing the second field. By default, this component is a Tkinter.Canvas. Its component group is <strong>Arrow</strong>.</p>
176 <a name=component.frame></a>
177 <dl><dt> <strong>frame
179 If the <strong>label</strong> component has been created (that is, the <strong>labelpos</strong>
180 option is not <strong>None</strong>), the <strong>frame</strong> component is created to act as
181 the container of the entry fields and arrow buttons. If there is
182 no <strong>label</strong> component, then no <strong>frame</strong> component is created and the
183 <strong>hull</strong> component acts as the container. In either case the border
184 around the container of the entry fields and arrow buttons will be
185 raised (but not around the label). By default, this component is a Tkinter.Frame.</p>
189 <a name=component.hourentryfield></a>
190 <dl><dt> <strong>hourentryfield
192 The entry field where the hours are entered and displayed. By default, this component is a <a href="EntryField.html">Pmw.EntryField</a>.</p>
196 <a name=component.hull></a>
197 <dl><dt> <strong>hull
199 This acts as the body for the entire megawidget. Other components
200 are created as children of the hull to further specialise this
201 class. By default, this component is a Tkinter.Frame.</p>
205 <a name=component.label></a>
206 <dl><dt> <strong>label
208 If the <strong>labelpos</strong> option is not <strong>None</strong>, this component is
209 created as a text label for the megawidget. See the
210 <strong>labelpos</strong> option for details. Note that to set, for example,
211 the <strong>text</strong> option of the label, you need to use the <strong>label_text</strong>
212 component option. By default, this component is a Tkinter.Label.</p>
216 <a name=component.minuteentryfield></a>
217 <dl><dt> <strong>minuteentryfield
219 The entry field where the minutes are entered and displayed. By default, this component is a <a href="EntryField.html">Pmw.EntryField</a>.</p>
223 <a name=component.secondentryfield></a>
224 <dl><dt> <strong>secondentryfield
226 The entry field where the seconds are entered and displayed. By default, this component is a <a href="EntryField.html">Pmw.EntryField</a>.</p>
230 <a name=component.uphourarrow></a>
231 <dl><dt> <strong>uphourarrow
233 The arrow button used for incrementing the hour field. By default, this component is a Tkinter.Canvas. Its component group is <strong>Arrow</strong>.</p>
237 <a name=component.upminutearrow></a>
238 <dl><dt> <strong>upminutearrow
240 The arrow button used for incrementing the minute field. By default, this component is a Tkinter.Canvas. Its component group is <strong>Arrow</strong>.</p>
244 <a name=component.upsecondarrow></a>
245 <dl><dt> <strong>upsecondarrow
247 The arrow button used for incrementing the second field. By default, this component is a Tkinter.Canvas. Its component group is <strong>Arrow</strong>.</p>
252 <dt> <h3>Component aliases</h3></dt><dd>
253 Sub-components of components of this megawidget
254 may be accessed via the following aliases.<p></p>
255 <dl><dt> <strong>hourentry
257 Alias for <strong>hourentryfield_entry</strong>.
259 <dl><dt> <strong>minuteentry
261 Alias for <strong>minuteentryfield_entry</strong>.
263 <dl><dt> <strong>secondentry
265 Alias for <strong>secondentryfield_entry</strong>.
269 <dt> <h3>Methods</h3></dt><dd>
270 Only methods specific to this megawidget are described below.
271 For a description of its inherited methods, see the
272 manual for its base class
273 <strong><a href="MegaWidget.html#methods">Pmw.MegaWidget</a></strong>.
275 <a name=method.decrement></a>
276 <dl><dt> <strong>decrement</strong>(<em>seconds</em> = <strong>1</strong>)</dt><dd>
277 Decrement the time by <em>seconds</em> seconds.</p>
281 <a name=method.getint></a>
282 <dl><dt> <strong>getint</strong>()</dt><dd>
283 Return the currently displayed time as a number of seconds.</p>
287 <a name=method.getstring></a>
288 <dl><dt> <strong>getstring</strong>()</dt><dd>
289 Same as <code>getvalue()</code> method.</p>
293 <a name=method.getvalue></a>
294 <dl><dt> <strong>getvalue</strong>()</dt><dd>
295 Return the currently displayed time as a string in the form
300 <a name=method.increment></a>
301 <dl><dt> <strong>increment</strong>(<em>seconds</em> = <strong>1</strong>)</dt><dd>
302 Increment the time by <em>seconds</em> seconds.</p>
306 <a name=method.invoke></a>
307 <dl><dt> <strong>invoke</strong>()</dt><dd>
308 Invoke the command specified by the <strong>command</strong> option as if the
309 <strong><Return></strong> key had been pressed.</p>
313 <a name=method.setvalue></a>
314 <dl><dt> <strong>setvalue</strong>(<em>text</em>)</dt><dd>
315 Set the contents of the time counter, where <em>text</em> must be in the
321 <dt> <h3>Example</h3></dt><dd>
322 The image at the top of this manual is a snapshot
323 of the window (or part of the window) produced
324 by the following code.<p></p>
327 def __init__(self, parent):
328 self._time = Pmw.TimeCounter(parent,
330 label_text = 'HH:MM:SS',
333 self._time.pack(padx=10, pady=5)
335 button = Tkinter.Button(parent, text = 'Show', command = self.show)
339 stringVal = self._time.getstring()
340 intVal = self._time.getint()
341 print stringVal + ' (' + str(intVal) + ')'
347 <center><P ALIGN="CENTER">
348 <IMG SRC = blue_line.gif ALT = "" WIDTH=320 HEIGHT=5>
353 <center><P ALIGN="CENTER">
356 - <a href="index.html">Home</a>
357 <br>Manual page last reviewed: 25 May 2002