Phoenix Logo

phoenix_title wx.adv.TimePickerCtrl

This control allows the user to enter time.

It is similar to wx.adv.DatePickerCtrl but is used for time, and not date, selection. While GetValue and SetValue still work with values of type wx.DateTime (because wxWidgets doesn’t provide a time-only class), their date part is ignored by this control.

It is only available if USE_TIMEPICKCTRL is set to 1.

This control currently doesn’t have any specific flags.

events Events Emitted by this Class

Handlers bound for the following event types will receive a wx.adv.DateEvent parameter.

  • EVT_TIME_CHANGED: This event fires when the user changes the current selection in the control.

New in version 2.9.3.


class_hierarchy Class Hierarchy

Inheritance diagram for class TimePickerCtrl:

appearance Control Appearance


wxMSW

wxMSW

wxMAC

wxMAC

wxGTK

wxGTK


method_summary Methods Summary

__init__ Default constructor.
Create Create the control window.
GetTime Returns the currently entered time as hours, minutes and seconds.
GetValue Returns the currently entered time.
SetTime Changes the current time of the control.
SetValue Changes the current value of the control.

property_summary Properties Summary

Value See GetValue and SetValue

api Class API



class wx.adv.TimePickerCtrl(Control)

Possible constructors:

TimePickerCtrl()

TimePickerCtrl(parent, id=ID_ANY, dt=DefaultDateTime,
               pos=DefaultPosition, size=DefaultSize, style=TP_DEFAULT,
               validator=DefaultValidator, name="timectrl")

This control allows the user to enter time.


Methods



__init__(self, *args, **kw)

overload Overloaded Implementations:



__init__ (self)

Default constructor.



__init__ (self, parent, id=ID_ANY, dt=DefaultDateTime, pos=DefaultPosition, size=DefaultSize, style=TP_DEFAULT, validator=DefaultValidator, name=”timectrl”)

Initializes the object and calls Create with all the parameters.

Parameters:





Create(self, parent, id=ID_ANY, dt=DefaultDateTime, pos=DefaultPosition, size=DefaultSize, style=DP_DEFAULT|DP_SHOWCENTURY, validator=DefaultValidator, name="timectrl")

Create the control window.

This method should only be used for objects created using default constructor.

Parameters:
  • parent (wx.Window) – Parent window, must not be not None.
  • id (wx.WindowID) – The identifier for the control.
  • dt (wx.DateTime) – The initial value of the control, if an invalid date (such as the default value) is used, the control is set to current time.
  • pos (wx.Point) – Initial position.
  • size (wx.Size) – Initial size. If left at default value, the control chooses its own best size by using the height approximately equal to a text control and width large enough to show the time fully.
  • style (long) – The window style, should be left at 0 as there are no special styles for this control in this version.
  • validator (wx.Validator) – Validator which can be used for additional checks.
  • name (string) – Control name.
Return type:

bool

Returns:

True if the control was successfully created or False if creation failed.



GetTime(self)

Returns the currently entered time as hours, minutes and seconds.

All the arguments must be not None, False is returned otherwise and none of them is modified.

Return type:tuple
Returns:( hour, min, sec )

New in version 2.9.4.

See also

SetTime



GetValue(self)

Returns the currently entered time.

The date part of the returned wx.DateTime object is always set to today and should be ignored, only the time part is relevant.

Return type:DateTime


SetTime(self, hour, min, sec)

Changes the current time of the control.

Calling this method does not result in a time change event.

Parameters:
  • hour (int) – The new hour value in 0..23 interval.
  • min (int) – The new minute value in 0..59 interval.
  • sec (int) – The new second value in 0..59 interval.
Return type:

bool

Returns:

True if the time was changed or False on failure, e.g. if the time components were invalid.

New in version 2.9.4.

See also

GetTime



SetValue(self, dt)

Changes the current value of the control.

The date part of dt is ignored, only the time part is displayed in the control. The dt object must however be valid.

In particular notice that it is a bad idea to use default wx.DateTime constructor from hour, minute and second values as it uses the today date for the date part which means that some times can be invalid if today happens to be the day of DST change. For example, when switching to summer time the time 2:00 typically doesn’t exist as the clocks jump directly to 3:00. To avoid this problem, use a fixed date on which DST is known not to change (e.g. Jan 1, 2012) for the date part of the argument or use SetTime .

Calling this method does not result in a time change event.

Parameters:dt (wx.DateTime) –

Properties



Value

See GetValue and SetValue