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.
^^
Handlers bound for the following event types will receive a wx.adv.DateEvent parameter.
EVT_TIME_CHANGED: Process a wxEVT_TIME_CHANGED event, which fires when the user changes the current selection in the control. ^^
New in version 2.9.3.
Default constructor. |
|
Create the control window. |
|
Returns the currently entered time as hours, minutes and seconds. |
|
Returns the currently entered time. |
|
Changes the current time of the control. |
|
Changes the current value of the control. |
wx.adv.
TimePickerCtrl
(Control)¶Possible constructors:
TimePickerCtrl()
TimePickerCtrl(parent, id=ID_ANY, dt=DefaultDateTime,
pos=DefaultPosition, size=DefaultSize, style=TP_DEFAULT,
validator=DefaultValidator, name=TimePickerCtrlNameStr)
This control allows the user to enter time.
__init__
(self, *args, **kw)¶__init__ (self)
Default constructor.
__init__ (self, parent, id=ID_ANY, dt=DefaultDateTime, pos=DefaultPosition, size=DefaultSize, style=TP_DEFAULT, validator=DefaultValidator, name=TimePickerCtrlNameStr)
Initializes the object and calls Create
with all the parameters.
parent (wx.Window) –
id (wx.WindowID) –
dt (wx.DateTime) –
pos (wx.Point) –
size (wx.Size) –
style (long) –
validator (wx.Validator) –
name (string) –
Create
(self, parent, id=ID_ANY, dt=DefaultDateTime, pos=DefaultPosition, size=DefaultSize, style=TP_DEFAULT, validator=DefaultValidator, name=TimePickerCtrlNameStr)¶Create the control window.
This method should only be used for objects created using default constructor.
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.
bool
True
if the control was successfully created or False
if creation failed.
GetClassDefaultAttributes
(variant=WINDOW_VARIANT_NORMAL)¶variant (WindowVariant) –
VisualAttributes
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.
tuple
( hour, min, sec )
New in version 2.9.4.
See also
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.
DateTime
SetTime
(self, hour, min, sec)¶Changes the current time of the control.
Calling this method does not result in a time change event.
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.
bool
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
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 values 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.
dt (wx.DateTime) –