1 # This file was created automatically by SWIG.
2 # Don't modify this file, modify the SWIG interface instead.
5 Classes for an interactive Calendar control.
13 __docfilter__
= wx
.__DocFilter
(globals())
14 CAL_SUNDAY_FIRST
= _calendar
.CAL_SUNDAY_FIRST
15 CAL_MONDAY_FIRST
= _calendar
.CAL_MONDAY_FIRST
16 CAL_SHOW_HOLIDAYS
= _calendar
.CAL_SHOW_HOLIDAYS
17 CAL_NO_YEAR_CHANGE
= _calendar
.CAL_NO_YEAR_CHANGE
18 CAL_NO_MONTH_CHANGE
= _calendar
.CAL_NO_MONTH_CHANGE
19 CAL_SEQUENTIAL_MONTH_SELECTION
= _calendar
.CAL_SEQUENTIAL_MONTH_SELECTION
20 CAL_SHOW_SURROUNDING_WEEKS
= _calendar
.CAL_SHOW_SURROUNDING_WEEKS
21 CAL_HITTEST_NOWHERE
= _calendar
.CAL_HITTEST_NOWHERE
22 CAL_HITTEST_HEADER
= _calendar
.CAL_HITTEST_HEADER
23 CAL_HITTEST_DAY
= _calendar
.CAL_HITTEST_DAY
24 CAL_HITTEST_INCMONTH
= _calendar
.CAL_HITTEST_INCMONTH
25 CAL_HITTEST_DECMONTH
= _calendar
.CAL_HITTEST_DECMONTH
26 CAL_HITTEST_SURROUNDING_WEEK
= _calendar
.CAL_HITTEST_SURROUNDING_WEEK
27 CAL_BORDER_NONE
= _calendar
.CAL_BORDER_NONE
28 CAL_BORDER_SQUARE
= _calendar
.CAL_BORDER_SQUARE
29 CAL_BORDER_ROUND
= _calendar
.CAL_BORDER_ROUND
30 class CalendarDateAttr(object):
32 A set of customization attributes for a calendar date, which can be
33 used to control the look of the Calendar object.
36 return "<%s.%s; proxy of C++ wxCalendarDateAttr instance at %s>" % (self
.__class
__.__module
__, self
.__class
__.__name
__, self
.this
,)
37 def __init__(self
, *args
, **kwargs
):
39 __init__(self, Colour colText=wxNullColour, Colour colBack=wxNullColour,
40 Colour colBorder=wxNullColour, Font font=wxNullFont,
41 int border=CAL_BORDER_NONE) -> CalendarDateAttr
43 Create a CalendarDateAttr.
45 newobj
= _calendar
.new_CalendarDateAttr(*args
, **kwargs
)
46 self
.this
= newobj
.this
49 def SetTextColour(*args
, **kwargs
):
50 """SetTextColour(self, Colour colText)"""
51 return _calendar
.CalendarDateAttr_SetTextColour(*args
, **kwargs
)
53 def SetBackgroundColour(*args
, **kwargs
):
54 """SetBackgroundColour(self, Colour colBack)"""
55 return _calendar
.CalendarDateAttr_SetBackgroundColour(*args
, **kwargs
)
57 def SetBorderColour(*args
, **kwargs
):
58 """SetBorderColour(self, Colour col)"""
59 return _calendar
.CalendarDateAttr_SetBorderColour(*args
, **kwargs
)
61 def SetFont(*args
, **kwargs
):
62 """SetFont(self, Font font)"""
63 return _calendar
.CalendarDateAttr_SetFont(*args
, **kwargs
)
65 def SetBorder(*args
, **kwargs
):
66 """SetBorder(self, int border)"""
67 return _calendar
.CalendarDateAttr_SetBorder(*args
, **kwargs
)
69 def SetHoliday(*args
, **kwargs
):
70 """SetHoliday(self, bool holiday)"""
71 return _calendar
.CalendarDateAttr_SetHoliday(*args
, **kwargs
)
73 def HasTextColour(*args
, **kwargs
):
74 """HasTextColour(self) -> bool"""
75 return _calendar
.CalendarDateAttr_HasTextColour(*args
, **kwargs
)
77 def HasBackgroundColour(*args
, **kwargs
):
78 """HasBackgroundColour(self) -> bool"""
79 return _calendar
.CalendarDateAttr_HasBackgroundColour(*args
, **kwargs
)
81 def HasBorderColour(*args
, **kwargs
):
82 """HasBorderColour(self) -> bool"""
83 return _calendar
.CalendarDateAttr_HasBorderColour(*args
, **kwargs
)
85 def HasFont(*args
, **kwargs
):
86 """HasFont(self) -> bool"""
87 return _calendar
.CalendarDateAttr_HasFont(*args
, **kwargs
)
89 def HasBorder(*args
, **kwargs
):
90 """HasBorder(self) -> bool"""
91 return _calendar
.CalendarDateAttr_HasBorder(*args
, **kwargs
)
93 def IsHoliday(*args
, **kwargs
):
94 """IsHoliday(self) -> bool"""
95 return _calendar
.CalendarDateAttr_IsHoliday(*args
, **kwargs
)
97 def GetTextColour(*args
, **kwargs
):
98 """GetTextColour(self) -> Colour"""
99 return _calendar
.CalendarDateAttr_GetTextColour(*args
, **kwargs
)
101 def GetBackgroundColour(*args
, **kwargs
):
102 """GetBackgroundColour(self) -> Colour"""
103 return _calendar
.CalendarDateAttr_GetBackgroundColour(*args
, **kwargs
)
105 def GetBorderColour(*args
, **kwargs
):
106 """GetBorderColour(self) -> Colour"""
107 return _calendar
.CalendarDateAttr_GetBorderColour(*args
, **kwargs
)
109 def GetFont(*args
, **kwargs
):
110 """GetFont(self) -> Font"""
111 return _calendar
.CalendarDateAttr_GetFont(*args
, **kwargs
)
113 def GetBorder(*args
, **kwargs
):
114 """GetBorder(self) -> int"""
115 return _calendar
.CalendarDateAttr_GetBorder(*args
, **kwargs
)
118 class CalendarDateAttrPtr(CalendarDateAttr
):
119 def __init__(self
, this
):
121 if not hasattr(self
,"thisown"): self
.thisown
= 0
122 self
.__class
__ = CalendarDateAttr
123 _calendar
.CalendarDateAttr_swigregister(CalendarDateAttrPtr
)
125 class CalendarEvent(_core
.CommandEvent
):
127 return "<%s.%s; proxy of C++ wxCalendarEvent instance at %s>" % (self
.__class
__.__module
__, self
.__class
__.__name
__, self
.this
,)
128 def __init__(self
, *args
, **kwargs
):
129 """__init__(self, CalendarCtrl cal, wxEventType type) -> CalendarEvent"""
130 newobj
= _calendar
.new_CalendarEvent(*args
, **kwargs
)
131 self
.this
= newobj
.this
134 def GetDate(*args
, **kwargs
):
135 """GetDate(self) -> DateTime"""
136 return _calendar
.CalendarEvent_GetDate(*args
, **kwargs
)
138 def SetDate(*args
, **kwargs
):
139 """SetDate(self, DateTime date)"""
140 return _calendar
.CalendarEvent_SetDate(*args
, **kwargs
)
142 def SetWeekDay(*args
, **kwargs
):
143 """SetWeekDay(self, int wd)"""
144 return _calendar
.CalendarEvent_SetWeekDay(*args
, **kwargs
)
146 def GetWeekDay(*args
, **kwargs
):
147 """GetWeekDay(self) -> int"""
148 return _calendar
.CalendarEvent_GetWeekDay(*args
, **kwargs
)
150 def PySetDate(self
, date
):
151 """takes datetime.datetime or datetime.date object"""
152 self
.SetDate(_py2wx(date
))
155 """returns datetime.date object"""
156 return _wx2py(self
.GetDate())
159 class CalendarEventPtr(CalendarEvent
):
160 def __init__(self
, this
):
162 if not hasattr(self
,"thisown"): self
.thisown
= 0
163 self
.__class
__ = CalendarEvent
164 _calendar
.CalendarEvent_swigregister(CalendarEventPtr
)
166 wxEVT_CALENDAR_DOUBLECLICKED
= _calendar
.wxEVT_CALENDAR_DOUBLECLICKED
167 wxEVT_CALENDAR_SEL_CHANGED
= _calendar
.wxEVT_CALENDAR_SEL_CHANGED
168 wxEVT_CALENDAR_DAY_CHANGED
= _calendar
.wxEVT_CALENDAR_DAY_CHANGED
169 wxEVT_CALENDAR_MONTH_CHANGED
= _calendar
.wxEVT_CALENDAR_MONTH_CHANGED
170 wxEVT_CALENDAR_YEAR_CHANGED
= _calendar
.wxEVT_CALENDAR_YEAR_CHANGED
171 wxEVT_CALENDAR_WEEKDAY_CLICKED
= _calendar
.wxEVT_CALENDAR_WEEKDAY_CLICKED
172 EVT_CALENDAR
= wx
.PyEventBinder( wxEVT_CALENDAR_DOUBLECLICKED
, 1)
173 EVT_CALENDAR_SEL_CHANGED
= wx
.PyEventBinder( wxEVT_CALENDAR_SEL_CHANGED
, 1)
174 EVT_CALENDAR_DAY
= wx
.PyEventBinder( wxEVT_CALENDAR_DAY_CHANGED
, 1)
175 EVT_CALENDAR_MONTH
= wx
.PyEventBinder( wxEVT_CALENDAR_MONTH_CHANGED
, 1)
176 EVT_CALENDAR_YEAR
= wx
.PyEventBinder( wxEVT_CALENDAR_YEAR_CHANGED
, 1)
177 EVT_CALENDAR_WEEKDAY_CLICKED
= wx
.PyEventBinder( wxEVT_CALENDAR_WEEKDAY_CLICKED
, 1)
179 class CalendarCtrl(_core
.Control
):
181 The calendar control allows the user to pick a date interactively.
183 The CalendarCtrl displays a window containing several parts: the
184 control to pick the month and the year at the top (either or both of
185 them may be disabled) and a month area below them which shows all the
186 days in the month. The user can move the current selection using the
187 keyboard and select the date (generating EVT_CALENDAR event) by
188 pressing <Return> or double clicking it.
190 It has advanced possibilities for the customization of its
191 display. All global settings (such as colours and fonts used) can, of
192 course, be changed. But also, the display style for each day in the
193 month can be set independently using CalendarDateAttr class.
195 An item without custom attributes is drawn with the default colours
196 and font and without border, but setting custom attributes with
197 SetAttr allows to modify its appearance. Just create a custom
198 attribute object and set it for the day you want to be displayed
199 specially A day may be marked as being a holiday, (even if it is not
200 recognized as one by wx.DateTime) by using the SetHoliday method.
202 As the attributes are specified for each day, they may change when the
203 month is changed, so you will often want to update them in an
204 EVT_CALENDAR_MONTH event handler.
207 return "<%s.%s; proxy of C++ wxCalendarCtrl instance at %s>" % (self
.__class
__.__module
__, self
.__class
__.__name
__, self
.this
,)
208 def __init__(self
, *args
, **kwargs
):
210 __init__(self, Window parent, int id=-1, DateTime date=DefaultDateTime,
211 Point pos=DefaultPosition, Size size=DefaultSize,
212 long style=wxCAL_SHOW_HOLIDAYS|wxWANTS_CHARS,
213 String name=CalendarNameStr) -> CalendarCtrl
215 Create and show a calendar control.
217 newobj
= _calendar
.new_CalendarCtrl(*args
, **kwargs
)
218 self
.this
= newobj
.this
221 self
._setOORInfo
(self
)
223 def Create(*args
, **kwargs
):
225 Create(self, Window parent, int id, DateTime date=DefaultDateTime,
226 Point pos=DefaultPosition, Size size=DefaultSize,
227 long style=wxCAL_SHOW_HOLIDAYS|wxWANTS_CHARS,
228 String name=CalendarNameStr) -> bool
230 Acutally create the GUI portion of the CalendarCtrl for 2-phase
233 return _calendar
.CalendarCtrl_Create(*args
, **kwargs
)
235 def SetDate(*args
, **kwargs
):
237 SetDate(self, DateTime date)
239 Sets the current date.
241 return _calendar
.CalendarCtrl_SetDate(*args
, **kwargs
)
243 def GetDate(*args
, **kwargs
):
245 GetDate(self) -> DateTime
247 Gets the currently selected date.
249 return _calendar
.CalendarCtrl_GetDate(*args
, **kwargs
)
251 def SetLowerDateLimit(*args
, **kwargs
):
253 SetLowerDateLimit(self, DateTime date=DefaultDateTime) -> bool
255 set the range in which selection can occur
257 return _calendar
.CalendarCtrl_SetLowerDateLimit(*args
, **kwargs
)
259 def SetUpperDateLimit(*args
, **kwargs
):
261 SetUpperDateLimit(self, DateTime date=DefaultDateTime) -> bool
263 set the range in which selection can occur
265 return _calendar
.CalendarCtrl_SetUpperDateLimit(*args
, **kwargs
)
267 def GetLowerDateLimit(*args
, **kwargs
):
269 GetLowerDateLimit(self) -> DateTime
271 get the range in which selection can occur
273 return _calendar
.CalendarCtrl_GetLowerDateLimit(*args
, **kwargs
)
275 def GetUpperDateLimit(*args
, **kwargs
):
277 GetUpperDateLimit(self) -> DateTime
279 get the range in which selection can occur
281 return _calendar
.CalendarCtrl_GetUpperDateLimit(*args
, **kwargs
)
283 def SetDateRange(*args
, **kwargs
):
285 SetDateRange(self, DateTime lowerdate=DefaultDateTime, DateTime upperdate=DefaultDateTime) -> bool
287 set the range in which selection can occur
289 return _calendar
.CalendarCtrl_SetDateRange(*args
, **kwargs
)
291 def EnableYearChange(*args
, **kwargs
):
293 EnableYearChange(self, bool enable=True)
295 This function should be used instead of changing CAL_NO_YEAR_CHANGE
296 style bit directly. It allows or disallows the user to change the year
299 return _calendar
.CalendarCtrl_EnableYearChange(*args
, **kwargs
)
301 def EnableMonthChange(*args
, **kwargs
):
303 EnableMonthChange(self, bool enable=True)
305 This function should be used instead of changing CAL_NO_MONTH_CHANGE
306 style bit. It allows or disallows the user to change the month
307 interactively. Note that if the month can not be changed, the year can
308 not be changed either.
310 return _calendar
.CalendarCtrl_EnableMonthChange(*args
, **kwargs
)
312 def EnableHolidayDisplay(*args
, **kwargs
):
314 EnableHolidayDisplay(self, bool display=True)
316 This function should be used instead of changing CAL_SHOW_HOLIDAYS
317 style bit directly. It enables or disables the special highlighting of
320 return _calendar
.CalendarCtrl_EnableHolidayDisplay(*args
, **kwargs
)
322 def SetHeaderColours(*args
, **kwargs
):
324 SetHeaderColours(self, Colour colFg, Colour colBg)
326 Header colours are used for painting the weekdays at the top.
328 return _calendar
.CalendarCtrl_SetHeaderColours(*args
, **kwargs
)
330 def GetHeaderColourFg(*args
, **kwargs
):
332 GetHeaderColourFg(self) -> Colour
334 Header colours are used for painting the weekdays at the top.
336 return _calendar
.CalendarCtrl_GetHeaderColourFg(*args
, **kwargs
)
338 def GetHeaderColourBg(*args
, **kwargs
):
340 GetHeaderColourBg(self) -> Colour
342 Header colours are used for painting the weekdays at the top.
344 return _calendar
.CalendarCtrl_GetHeaderColourBg(*args
, **kwargs
)
346 def SetHighlightColours(*args
, **kwargs
):
348 SetHighlightColours(self, Colour colFg, Colour colBg)
350 Highlight colour is used for the currently selected date.
352 return _calendar
.CalendarCtrl_SetHighlightColours(*args
, **kwargs
)
354 def GetHighlightColourFg(*args
, **kwargs
):
356 GetHighlightColourFg(self) -> Colour
358 Highlight colour is used for the currently selected date.
360 return _calendar
.CalendarCtrl_GetHighlightColourFg(*args
, **kwargs
)
362 def GetHighlightColourBg(*args
, **kwargs
):
364 GetHighlightColourBg(self) -> Colour
366 Highlight colour is used for the currently selected date.
368 return _calendar
.CalendarCtrl_GetHighlightColourBg(*args
, **kwargs
)
370 def SetHolidayColours(*args
, **kwargs
):
372 SetHolidayColours(self, Colour colFg, Colour colBg)
374 Holiday colour is used for the holidays (if CAL_SHOW_HOLIDAYS style is
377 return _calendar
.CalendarCtrl_SetHolidayColours(*args
, **kwargs
)
379 def GetHolidayColourFg(*args
, **kwargs
):
381 GetHolidayColourFg(self) -> Colour
383 Holiday colour is used for the holidays (if CAL_SHOW_HOLIDAYS style is
386 return _calendar
.CalendarCtrl_GetHolidayColourFg(*args
, **kwargs
)
388 def GetHolidayColourBg(*args
, **kwargs
):
390 GetHolidayColourBg(self) -> Colour
392 Holiday colour is used for the holidays (if CAL_SHOW_HOLIDAYS style is
395 return _calendar
.CalendarCtrl_GetHolidayColourBg(*args
, **kwargs
)
397 def GetAttr(*args
, **kwargs
):
399 GetAttr(self, size_t day) -> CalendarDateAttr
401 Returns the attribute for the given date (should be in the range
402 1...31). The returned value may be None
404 return _calendar
.CalendarCtrl_GetAttr(*args
, **kwargs
)
406 def SetAttr(*args
, **kwargs
):
408 SetAttr(self, size_t day, CalendarDateAttr attr)
410 Associates the attribute with the specified date (in the range
411 1...31). If the attribute passed is None, the items attribute is
414 return _calendar
.CalendarCtrl_SetAttr(*args
, **kwargs
)
416 def SetHoliday(*args
, **kwargs
):
418 SetHoliday(self, size_t day)
420 Marks the specified day as being a holiday in the current month.
422 return _calendar
.CalendarCtrl_SetHoliday(*args
, **kwargs
)
424 def ResetAttr(*args
, **kwargs
):
426 ResetAttr(self, size_t day)
428 Clears any attributes associated with the given day (in the range
431 return _calendar
.CalendarCtrl_ResetAttr(*args
, **kwargs
)
433 def HitTest(*args
, **kwargs
):
435 HitTest(Point pos) -> (result, date, weekday)
437 Returns 3-tuple with information about the given position on the
438 calendar control. The first value of the tuple is a result code and
439 determines the validity of the remaining two values.
441 return _calendar
.CalendarCtrl_HitTest(*args
, **kwargs
)
443 def GetMonthControl(*args
, **kwargs
):
445 GetMonthControl(self) -> Control
447 Get the currently shown control for month.
449 return _calendar
.CalendarCtrl_GetMonthControl(*args
, **kwargs
)
451 def GetYearControl(*args
, **kwargs
):
453 GetYearControl(self) -> Control
455 Get the currently shown control for year.
457 return _calendar
.CalendarCtrl_GetYearControl(*args
, **kwargs
)
459 def GetClassDefaultAttributes(*args
, **kwargs
):
461 GetClassDefaultAttributes(int variant=WINDOW_VARIANT_NORMAL) -> VisualAttributes
463 Get the default attributes for this class. This is useful if you want
464 to use the same font or colour in your own control as in a standard
465 control -- which is a much better idea than hard coding specific
466 colours or fonts which might look completely out of place on the
467 user's system, especially if it uses themes.
469 The variant parameter is only relevant under Mac currently and is
470 ignore under other platforms. Under Mac, it will change the size of
471 the returned font. See `wx.Window.SetWindowVariant` for more about
474 return _calendar
.CalendarCtrl_GetClassDefaultAttributes(*args
, **kwargs
)
476 GetClassDefaultAttributes
= staticmethod(GetClassDefaultAttributes
)
477 def PySetDate(self
, date
):
478 """takes datetime.datetime or datetime.date object"""
479 self
.SetDate(_py2wx(date
))
482 """returns datetime.date object"""
483 return _wx2py(self
.GetDate())
485 def PySetLowerDateLimit(self
, date
):
486 """takes datetime.datetime or datetime.date object"""
487 self
.SetLowerDateLimit(_py2wx(date
))
489 def PySetUpperDateLimit(self
, date
):
490 """takes datetime.datetime or datetime.date object"""
491 self
.SetUpperDateLimit(_py2wx(date
))
493 def PySetDateRange(self
, lowerdate
, upperdate
):
494 """takes datetime.datetime or datetime.date objects"""
495 self
.PySetLowerDateLimit(lowerdate
)
496 self
.PySetUpperDateLimit(upperdate
)
498 def PyGetLowerDateLimit(self
):
499 """returns datetime.date object"""
500 return _wx2py(self
.GetLowerDateLimit())
502 def PyGetUpperDateLimit(self
):
503 """returns datetime.date object"""
504 return _wx2py(self
.GetUpperDateLimit())
507 class CalendarCtrlPtr(CalendarCtrl
):
508 def __init__(self
, this
):
510 if not hasattr(self
,"thisown"): self
.thisown
= 0
511 self
.__class
__ = CalendarCtrl
512 _calendar
.CalendarCtrl_swigregister(CalendarCtrlPtr
)
513 cvar
= _calendar
.cvar
514 CalendarNameStr
= cvar
.CalendarNameStr
516 def PreCalendarCtrl(*args
, **kwargs
):
518 PreCalendarCtrl() -> CalendarCtrl
520 Precreate a CalendarCtrl for 2-phase creation.
522 val
= _calendar
.new_PreCalendarCtrl(*args
, **kwargs
)
526 def CalendarCtrl_GetClassDefaultAttributes(*args
, **kwargs
):
528 CalendarCtrl_GetClassDefaultAttributes(int variant=WINDOW_VARIANT_NORMAL) -> VisualAttributes
530 Get the default attributes for this class. This is useful if you want
531 to use the same font or colour in your own control as in a standard
532 control -- which is a much better idea than hard coding specific
533 colours or fonts which might look completely out of place on the
534 user's system, especially if it uses themes.
536 The variant parameter is only relevant under Mac currently and is
537 ignore under other platforms. Under Mac, it will change the size of
538 the returned font. See `wx.Window.SetWindowVariant` for more about
541 return _calendar
.CalendarCtrl_GetClassDefaultAttributes(*args
, **kwargs
)
545 assert isinstance(date
, (datetime
.datetime
, datetime
.date
))
546 tt
= date
.timetuple()
547 dmy
= (tt
[2], tt
[1]-1, tt
[0])
548 return wx
.DateTimeFromDMY(*dmy
)
552 assert isinstance(date
, wx
.DateTime
)
553 ymd
= map(int, date
.FormatISODate().split('-'))
554 return datetime
.date(*ymd
)