Pmw.Counter

Name

Pmw.Counter() - entry field with up and down arrow buttons

Inherits

Pmw.MegaWidget

Description

This class consists of an entry field with arrow buttons to increment and decrement the value in the entry field. Built-in entry types include numbers, times and dates. An external counting function may also be supplied. The entry field's validation function is also available. The components may be laid out horizontally or vertically.

Options

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

autorepeat
Initialisation option. 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 the 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.

datatype
Specifies how the counter should count up and down. Must be one of the built-in datatypes or a function. The built-in datatypes support the incrementing and decrementing of numbers, times and dates. They are

 numeric        any integer
 integer        any integer
 real           real number
 timeN          HH:MM:SS (may be negative)
 time24         HH:MM:SS (wraps around at 23:59:59)
 date_dmy       DD/MM/YY
 date_mdy       MM/DD/YY
 date_ymd       YY/MM/DD
 date_dmy4      DD/MM/YYYY
 date_mdy4      MM/DD/YYYY
 date_y4md      YYYY/MM/DD

If validate is a function, then it will be called whenever the counter is incremented or decremented. The function is called with the arguments (text, factor, increment, min, max), where text is the current contents of the entry field, factor is 1 when incrementing or -1 when decrementing, and the other arguments are the values of the options of the same name.

The validate function should return a string representing the incremented or decremented value. It should raise an error if min or max would be exceeded or if the text is invalid. The default is 'numeric'.

increment
Specifies how many units should be added or subtracted when the counter is incremented or decremented. For the number datatypes, the value is a number. For the time datatypes, the value is in seconds. For the date datatypes, the value is in days. The default is 1.

initwait
Initialisation option. 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 centre 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 value. The counter will not increment above this value. For the number datatypes, the value is a number. For the time datatypes, the value is a time string. For the date datatypes, the value a date string. If '', no maximum will be enforced. The default is ''.

min
Specifies the minimum value. The counter will not decrement below this value. For the number datatypes, the value is a number. For the time datatypes, the value is a time string. For the date datatypes, the value a date string. If '', no minimum will be enforced. The default is ''.

orient
Initialisation option. Specifies whether the arrow buttons should appear to the left and right of the entry field ('horizontal') or above and below ('vertical'). The default is 'horizontal'.

padx
Initialisation option. Specifies a padding distance to leave around the arrow buttons in the x direction. The default is 0.

pady
Initialisation option. Specifies a padding distance to leave around the arrow buttons in the y direction. The default is 0.

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

Components

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

downarrow
The arrow button used for decrementing the counter. Depending on the value of orient, it will appear on the left or below the entry field. By default, this component is a Tkinter.Canvas. Its component group is Arrow.

entryfield
The entry field widget where the text is entered, displayed and validated. By default, this component is a Pmw.EntryField.

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 field and arrow buttons. If there is no label component, the hull component acts as the container. In either case the border around the container of the entry field and arrow buttons will be raised (but not around the label). By default, this component is a Tkinter.Frame.

hull
This acts as the body for the entire megawidget. Other components are created as children of the hull to further specialise the widget. 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 use the label_text component option. By default, this component is a Tkinter.Label.

uparrow
The arrow button used for incrementing the counter. Depending on the value of orient, it will appear on the right or above the entry 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.

entry
Alias for entryfield_entry.

Methods

Only methods specific to this megawidget are described below. For a description of its inherited methods, see the manuals for its base classes. In addition, methods from Pmw.EntryField are forwarded to this megawidget's entryfield component.

decrement()
Decrement the counter once, as if the down arrow had been pressed.

increment()
Increment the counter once, as if the up arrow had been pressed.

Home. Pmw 0.6.2 Maintainer gregm@iname.com. 23 Feb 1998