# 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. The default is 0.
  labelpos
    Initialisation option. 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
    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 2.0.0 - 29 Mar 2014 - Home
Manual page last reviewed: 25 May 2002