This control allows the user to select a date.
Unlike CalendarCtrl, which is a relatively big control, DatePickerCtrl is implemented as a small window showing the currently selected date. The control can be edited using the keyboard, and can also display a popup window for more user-friendly date selection, depending on the styles used and the platform.
It is only available if USE_DATEPICKCTRL is set to 1.
This class supports the following styles:
Handlers bound for the following event types will receive a DateEvent parameter.
See also
__init__ | Default constructor. |
Create | Create the control window. |
GetRange | If the control had been previously limited to a range of dates using SetRange , returns the lower and upper bounds of this range. |
GetValue | Returns the currently entered date. |
SetRange | Sets the valid range for the date selection. |
SetValue | Changes the current value of the control. |
This control allows the user to select a date.
Possible constructors:
DatePickerCtrlGeneric()
DatePickerCtrlGeneric(parent, id=ID_ANY, dt=DefaultDateTime,
pos=DefaultPosition, size=DefaultSize, style=DP_DEFAULT|DP_SHOWCENTURY,
validator=DefaultValidator, name="datectrl")
Overloaded Implementations:
__init__ (self)
Default constructor.
__init__ (self, parent, id=ID_ANY, dt=DefaultDateTime, pos=DefaultPosition, size=DefaultSize, style=DP_DEFAULT|DP_SHOWCENTURY, validator=DefaultValidator, name=”datectrl”)
Initializes the object and calls Create with all the parameters.
Parameters: |
---|
Create the control window.
This method should only be used for objects created using default constructor.
Parameters: |
|
---|---|
Return type: | bool |
Returns: | True if the control was successfully created or False if creation failed. |
If the control had been previously limited to a range of dates using SetRange , returns the lower and upper bounds of this range.
If no range is set (or only one of the bounds is set), dt1 and/or dt2 are set to be invalid.
Notice that when using a native MSW implementation of this control the lower range is always set, even if SetRange hadn’t been called explicitly, as the native control only supports dates later than year 1601.
Pointer to the object which receives the lower range limit or becomes invalid if it is not set. May be None if the caller is not interested in lower limit.
Same as above but for the upper limit.
Return type: | tuple |
---|---|
Returns: | ( bool, dt1, dt2 ) |
Returns the currently entered date.
For a control with DP_ALLOWNONE style the returned value may be invalid if no date is entered, otherwise it is always valid.
Return type: | DateTime |
---|
Sets the valid range for the date selection.
If dt1 is valid, it becomes the earliest date (inclusive) accepted by the control. If dt2 is valid, it becomes the latest possible date.
Parameters: |
---|
Note
If the current value of the control is outside of the newly set range bounds, the behaviour is undefined.
Changes the current value of the control.
The date should be valid unless the control was created with DP_ALLOWNONE style and included in the currently selected range, if any.
Calling this method does not result in a date change event.
Parameters: | dt (DateTime) – |
---|