The calendar control allows the user to pick a date.
The user can move the current selection using the keyboard and select the date (generating EVT_CALENDAR event) by pressing <Return> or float clicking it.
Generic calendar has advanced possibilities for the customization of its display, described below. If you want to use these possibilities on every platform, use GenericCalendarCtrl instead of CalendarCtrl.
All global settings (such as colours and fonts used) can, of course, be changed. But also, the display style for each day in the month can be set independently using CalendarDateAttr class.
An item without custom attributes is drawn with the default colours and font and without border, but setting custom attributes with SetAttr allows to modify its appearance. Just create a custom attribute object and set it for the day you want to be displayed specially (note that the control will take ownership of the pointer, i.e. it will delete it itself). A day may be marked as being a holiday, even if it is not recognized as one by DateTime using the CalendarDateAttr.SetHoliday method.
As the attributes are specified for each day, they may change when the month is changed, so you will often want to update them in EVT_CALENDAR_PAGE_CHANGED event handler.
This class supports the following styles:
Handlers bound for the following event types will receive a CalendarEvent parameter.
Implementations:GTK, MSW ports; a generic implementation is used elsewhere.
Note
Changing the selected date will trigger an EVT_CALENDAR_DAY, MONTH or YEAR event as well as an EVT_CALENDAR_SEL_CHANGED event.
See also
__init__ | Default constructor. |
Create | Creates the control. |
EnableHolidayDisplay | This function should be used instead of changing CAL_SHOW_HOLIDAYS style bit directly. |
EnableMonthChange | This function should be used instead of changing CAL_NO_MONTH_CHANGE style bit. |
GetAttr | Returns the attribute for the given date (should be in the range 1...31). |
GetDate | Gets the currently selected date. |
GetDateRange | Returns the limits currently being used. |
GetHeaderColourBg | Gets the background colour of the header part of the calendar window. |
GetHeaderColourFg | Gets the foreground colour of the header part of the calendar window. |
GetHighlightColourBg | Gets the background highlight colour. |
GetHighlightColourFg | Gets the foreground highlight colour. |
GetHolidayColourBg | Return the background colour currently used for holiday highlighting. |
GetHolidayColourFg | Return the foreground colour currently used for holiday highlighting. |
HitTest | Returns one of CalendarHitTestResult constants and fills either date or wd pointer with the corresponding value depending on the hit test code. |
Mark | Mark or unmark the day. |
ResetAttr | Clears any attributes associated with the given day (in the range 1...31). |
SetAttr | Associates the attribute with the specified date (in the range 1...31). |
SetDate | Sets the current date. |
SetDateRange | Restrict the dates that can be selected in the control to the specified range. |
SetHeaderColours | Set the colours used for painting the weekdays at the top of the control. |
SetHighlightColours | Set the colours to be used for highlighting the currently selected date. |
SetHoliday | Marks the specified day as being a holiday in the current month. |
SetHolidayColours | Sets the colours to be used for the holidays highlighting. |
The calendar control allows the user to pick a date.
Possible constructors:
CalendarCtrl()
CalendarCtrl(parent, id=ID_ANY, date=DefaultDateTime,
pos=DefaultPosition, size=DefaultSize, style=CAL_SHOW_HOLIDAYS,
name=CalendarNameStr)
Overloaded Implementations:
__init__ (self)
Default constructor.
__init__ (self, parent, id=ID_ANY, date=DefaultDateTime, pos=DefaultPosition, size=DefaultSize, style=CAL_SHOW_HOLIDAYS, name=CalendarNameStr)
Does the same as Create method.
Parameters: |
---|
Creates the control.
See Window.__init__ for the meaning of the parameters and the control overview for the possible styles.
Parameters: | |
---|---|
Return type: | bool |
This function should be used instead of changing CAL_SHOW_HOLIDAYS style bit directly.
It enables or disables the special highlighting of the holidays.
Parameters: | display (bool) – |
---|
This function should be used instead of changing CAL_NO_MONTH_CHANGE style bit.
It allows or disallows the user to change the month interactively. Note that if the month cannot be changed, the year cannot be changed neither.
Parameters: | enable (bool) – |
---|---|
Return type: | bool |
Returns: | True if the value of this option really changed or False if it was already set to the requested value. |
Returns the attribute for the given date (should be in the range 1...31).
The returned pointer may be None. Only in generic CalendarCtrl.
Parameters: | day (int) – |
---|---|
Return type: | CalendarDateAttr |
Returns the limits currently being used.
If not None, the value of the low limit for the dates shown by the control is returned (which may be DefaultDateTime if no limit is set).
If not None, the value of the upper limit for the dates shown by the control is returned (which may be DefaultDateTime if no limit is set).
Return type: | tuple |
---|---|
Returns: | ( bool, lowerdate, upperdate ) |
See also
Gets the background colour of the header part of the calendar window.
This method is currently only implemented in generic CalendarCtrl and always returns NullColour in the native versions.
Return type: | Colour |
---|
See also
Gets the foreground colour of the header part of the calendar window.
This method is currently only implemented in generic CalendarCtrl and always returns NullColour in the native versions.
Return type: | Colour |
---|
See also
Gets the background highlight colour.
Only in generic CalendarCtrl.
This method is currently only implemented in generic CalendarCtrl and always returns NullColour in the native versions.
Return type: | Colour |
---|
See also
Gets the foreground highlight colour.
Only in generic CalendarCtrl.
This method is currently only implemented in generic CalendarCtrl and always returns NullColour in the native versions.
Return type: | Colour |
---|
See also
Return the background colour currently used for holiday highlighting.
Only useful with generic CalendarCtrl as native versions currently don’t support holidays display at all and always return NullColour .
Return type: | Colour |
---|
See also
Return the foreground colour currently used for holiday highlighting.
Only useful with generic CalendarCtrl as native versions currently don’t support holidays display at all and always return NullColour .
Return type: | Colour |
---|
See also
Returns one of CalendarHitTestResult constants and fills either date or wd pointer with the corresponding value depending on the hit test code.
Not implemented in wxGTK currently.
Parameters: | pos (Point) – |
---|---|
Return type: | tuple |
Returns: | ( CalendarHitTestResult, date, wd ) |
Mark or unmark the day.
This day of month will be marked in every month. In generic CalendarCtrl,
Parameters: |
|
---|
Clears any attributes associated with the given day (in the range 1...31).
Only in generic CalendarCtrl.
Parameters: | day (int) – |
---|
Associates the attribute with the specified date (in the range 1...31).
If the pointer is None, the items attribute is cleared. Only in generic CalendarCtrl.
Parameters: |
|
---|
Sets the current date.
The date parameter must be valid and in the currently valid range as set by SetDateRange , otherwise the current date is not changed and the function returns False.
Parameters: | date (DateTime) – |
---|---|
Return type: | bool |
Restrict the dates that can be selected in the control to the specified range.
If either date is set, the corresponding limit will be enforced and True returned. If none are set, the existing restrictions are removed and False is returned.
Parameters: | |
---|---|
Return type: | bool |
Returns: | True if either limit is valid, False otherwise |
See also
Set the colours used for painting the weekdays at the top of the control.
This method is currently only implemented in generic CalendarCtrl and does nothing in the native versions.
Parameters: |
---|
Set the colours to be used for highlighting the currently selected date.
This method is currently only implemented in generic CalendarCtrl and does nothing in the native versions.
Parameters: |
---|
Marks the specified day as being a holiday in the current month.
This method is only implemented in the generic version of the control and does nothing in the native ones.
Parameters: | day (int) – |
---|
Sets the colours to be used for the holidays highlighting.
This method is only implemented in the generic version of the control and does nothing in the native ones. It should also only be called if the window style includes CAL_SHOW_HOLIDAYS flag or EnableHolidayDisplay had been called.
Parameters: |
---|
See GetDateRange and SetDateRange