Pmw.TimeCounter

Name

Pmw.TimeCounter() - counter for display and input of time

Inherits

Pmw.MegaWidget

Description

A time counter is similar to a regular Pmw.Counter except that the user may increment and decrement the hours, minutes and seconds individually.

Options

Options for this megawidget and its base classes are described below.

autorepeat
If true, the counter will continue to count up or down while an arrow button is held pressed down. The default is 1.

buttonaspect
Initialisation option. Specifies the width of the arrow buttons as a proportion of their height. Values less than 1.0 will produce thin arrow buttons. Values greater than 1.0 will produce fat arrow buttons. The default is 1.0.

command
This specifies a function to call whenever the <Return> key is pressed in one of the entry fields or invoke() is called. The default is None.

initwait
Specifies the initial delay (in milliseconds) before a depressed arrow button automatically starts to repeat counting. The default is 300.

labelmargin
Initialisation option. If the labelpos option is not None, this specifies the distance between the label component and the rest of the megawidget. The default is 0.

labelpos
Initialisation option. Specifies where to place the label component. If not None, it should be a concatenation of one or two of the letters 'n', 's', 'e' and 'w'. The first letter specifies on which side of the megawidget to place the label. If a second letter is specified, it indicates where on that side to place the label. For example, if labelpos is 'w', the label is placed in the center of the left hand side; if it is 'wn', the label is placed at the top of the left hand side; if it is 'ws', the label is placed at the bottom of the left hand side.

If None, a label component is not created. The default is None.

max
Specifies the maximum acceptable time in the form "HH:MM:SS", or None if no maximum checking should be performed. The default is None.

min
Specifies the minimum acceptable time in the form "HH:MM:SS", or None if no minimum checking should be performed. The default is None.

padx
Initialisation option. Specifies how much wider to make each column than the default width (where a column consists of two arrows and an entry field). The entry fields expand to fill the extra space, but the arrow buttons are centered in the available space. The default is 0.

pady
Initialisation option. Specifies how much higher to make each row of arrow buttons than the default hight. The arrow buttons are centered in the available space. The default is 0.

repeatrate
Specifies the delay (in milliseconds) between automatic counts while an arrow button is held pressed down. The default is 50.

value
Initialisation option. Specifies the initial contents of the time counter, in the form "HH:MM:SS". If this is None, the current time is used as the initial contents. The default is None.

Components

Components created by this megawidget and its base classes are described below.

downhourarrow
The arrow button used for decrementing the hour field. By default, this component is a Tkinter.Canvas. Its component group is Arrow.

downminutearrow
The arrow button used for decrementing the minute field. By default, this component is a Tkinter.Canvas. Its component group is Arrow.

downsecondarrow
The arrow button used for decrementing the second field. By default, this component is a Tkinter.Canvas. Its component group is Arrow.

frame
If the label component has been created (that is, the labelpos option is not None), the frame component is created to act as the container of the entry fields and arrow buttons. If there is no label component, then no frame component is created and the hull component acts as the container. In either case the border around the container of the entry fields and arrow buttons will be raised (but not around the label). By default, this component is a Tkinter.Frame.

hourentryfield
The entry field where the hours are entered and displayed. By default, this component is a Pmw.EntryField.

hull
This acts as the body for the entire megawidget. Other components are created as children of the hull to further specialise this class. By default, this component is a Tkinter.Frame.

label
If the labelpos option is not None, this component is created as a text label for the megawidget. See the labelpos option for details. Note that to set, for example, the text option of the label, you need to use the label_text component option. By default, this component is a Tkinter.Label.

minuteentryfield
The entry field where the minutes are entered and displayed. By default, this component is a Pmw.EntryField.

secondentryfield
The entry field where the seconds are entered and displayed. By default, this component is a Pmw.EntryField.

uphourarrow
The arrow button used for incrementing the hour field. By default, this component is a Tkinter.Canvas. Its component group is Arrow.

upminutearrow
The arrow button used for incrementing the minute field. By default, this component is a Tkinter.Canvas. Its component group is Arrow.

upsecondarrow
The arrow button used for incrementing the second field. By default, this component is a Tkinter.Canvas. Its component group is Arrow.

Component aliases

Sub-components of components of this megawidget may be accessed via the following aliases.

hourentry
Alias for hourentryfield_entry.
minuteentry
Alias for minuteentryfield_entry.
secondentry
Alias for secondentryfield_entry.

Methods

Only methods specific to this megawidget are described below. For a description of its inherited methods, see the manual for its base class Pmw.MegaWidget.

decrement(seconds = 1)
Decrement the time by seconds seconds.

getint()
Return the currently displayed time as a number of seconds.

getstring()
Same as getvalue() method.

getvalue()
Return the currently displayed time as a string in the form "HH:MM:SS".

increment(seconds = 1)
Increment the time by seconds seconds.

invoke()
Invoke the command specified by the command option as if the <Return> key had been pressed.

setvalue(text)
Set the contents of the time counter, where text must be in the form "HH:MM:SS".

Example

The image at the top of this manual is a snapshot of the window (or part of the window) produced by the following code.

class Demo:
    def __init__(self, parent):
        self._time = Pmw.TimeCounter(parent,
                labelpos = 'w',
                label_text = 'HH:MM:SS',
                min = '00:00:00',
                max = '23:59:59')
        self._time.pack(padx=10, pady=5)

        button = Tkinter.Button(parent, text = 'Show', command = self.show)
        button.pack()

    def show(self):
        stringVal = self._time.getstring()
        intVal =  self._time.getint()
        print stringVal + '  (' + str(intVal) + ')'

Pmw 1.2 - 5 Aug 2003 - Home
Manual page last reviewed: 25 May 2002