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.
10 def _swig_setattr_nondynamic(self
,class_type
,name
,value
,static
=1):
12 if isinstance(value
, class_type
):
13 self
.__dict
__[name
] = value
.this
14 if hasattr(value
,"thisown"): self
.__dict
__["thisown"] = value
.thisown
17 method
= class_type
.__swig
_setmethods
__.get(name
,None)
18 if method
: return method(self
,value
)
19 if (not static
) or hasattr(self
,name
) or (name
== "thisown"):
20 self
.__dict
__[name
] = value
22 raise AttributeError("You cannot add attributes to %s" % self
)
24 def _swig_setattr(self
,class_type
,name
,value
):
25 return _swig_setattr_nondynamic(self
,class_type
,name
,value
,0)
27 def _swig_getattr(self
,class_type
,name
):
28 method
= class_type
.__swig
_getmethods
__.get(name
,None)
29 if method
: return method(self
)
30 raise AttributeError,name
34 _object
= types
.ObjectType
36 except AttributeError:
42 def _swig_setattr_nondynamic_method(set):
43 def set_attr(self
,name
,value
):
44 if hasattr(self
,name
) or (name
in ("this", "thisown")):
47 raise AttributeError("You cannot add attributes to %s" % self
)
54 __docfilter__
= wx
.__DocFilter
(globals())
55 CAL_SUNDAY_FIRST
= _calendar
.CAL_SUNDAY_FIRST
56 CAL_MONDAY_FIRST
= _calendar
.CAL_MONDAY_FIRST
57 CAL_SHOW_HOLIDAYS
= _calendar
.CAL_SHOW_HOLIDAYS
58 CAL_NO_YEAR_CHANGE
= _calendar
.CAL_NO_YEAR_CHANGE
59 CAL_NO_MONTH_CHANGE
= _calendar
.CAL_NO_MONTH_CHANGE
60 CAL_SEQUENTIAL_MONTH_SELECTION
= _calendar
.CAL_SEQUENTIAL_MONTH_SELECTION
61 CAL_SHOW_SURROUNDING_WEEKS
= _calendar
.CAL_SHOW_SURROUNDING_WEEKS
62 CAL_HITTEST_NOWHERE
= _calendar
.CAL_HITTEST_NOWHERE
63 CAL_HITTEST_HEADER
= _calendar
.CAL_HITTEST_HEADER
64 CAL_HITTEST_DAY
= _calendar
.CAL_HITTEST_DAY
65 CAL_HITTEST_INCMONTH
= _calendar
.CAL_HITTEST_INCMONTH
66 CAL_HITTEST_DECMONTH
= _calendar
.CAL_HITTEST_DECMONTH
67 CAL_HITTEST_SURROUNDING_WEEK
= _calendar
.CAL_HITTEST_SURROUNDING_WEEK
68 CAL_BORDER_NONE
= _calendar
.CAL_BORDER_NONE
69 CAL_BORDER_SQUARE
= _calendar
.CAL_BORDER_SQUARE
70 CAL_BORDER_ROUND
= _calendar
.CAL_BORDER_ROUND
71 class CalendarDateAttr(object):
73 A set of customization attributes for a calendar date, which can be
74 used to control the look of the Calendar object.
77 return "<%s.%s; proxy of C++ wxCalendarDateAttr instance at %s>" % (self
.__class
__.__module
__, self
.__class
__.__name
__, self
.this
,)
78 def __init__(self
, *args
, **kwargs
):
80 __init__(self, Colour colText=wxNullColour, Colour colBack=wxNullColour,
81 Colour colBorder=wxNullColour, Font font=wxNullFont,
82 int border=CAL_BORDER_NONE) -> CalendarDateAttr
84 Create a CalendarDateAttr.
86 newobj
= _calendar
.new_CalendarDateAttr(*args
, **kwargs
)
87 self
.this
= newobj
.this
90 def SetTextColour(*args
, **kwargs
):
91 """SetTextColour(self, Colour colText)"""
92 return _calendar
.CalendarDateAttr_SetTextColour(*args
, **kwargs
)
94 def SetBackgroundColour(*args
, **kwargs
):
95 """SetBackgroundColour(self, Colour colBack)"""
96 return _calendar
.CalendarDateAttr_SetBackgroundColour(*args
, **kwargs
)
98 def SetBorderColour(*args
, **kwargs
):
99 """SetBorderColour(self, Colour col)"""
100 return _calendar
.CalendarDateAttr_SetBorderColour(*args
, **kwargs
)
102 def SetFont(*args
, **kwargs
):
103 """SetFont(self, Font font)"""
104 return _calendar
.CalendarDateAttr_SetFont(*args
, **kwargs
)
106 def SetBorder(*args
, **kwargs
):
107 """SetBorder(self, int border)"""
108 return _calendar
.CalendarDateAttr_SetBorder(*args
, **kwargs
)
110 def SetHoliday(*args
, **kwargs
):
111 """SetHoliday(self, bool holiday)"""
112 return _calendar
.CalendarDateAttr_SetHoliday(*args
, **kwargs
)
114 def HasTextColour(*args
, **kwargs
):
115 """HasTextColour(self) -> bool"""
116 return _calendar
.CalendarDateAttr_HasTextColour(*args
, **kwargs
)
118 def HasBackgroundColour(*args
, **kwargs
):
119 """HasBackgroundColour(self) -> bool"""
120 return _calendar
.CalendarDateAttr_HasBackgroundColour(*args
, **kwargs
)
122 def HasBorderColour(*args
, **kwargs
):
123 """HasBorderColour(self) -> bool"""
124 return _calendar
.CalendarDateAttr_HasBorderColour(*args
, **kwargs
)
126 def HasFont(*args
, **kwargs
):
127 """HasFont(self) -> bool"""
128 return _calendar
.CalendarDateAttr_HasFont(*args
, **kwargs
)
130 def HasBorder(*args
, **kwargs
):
131 """HasBorder(self) -> bool"""
132 return _calendar
.CalendarDateAttr_HasBorder(*args
, **kwargs
)
134 def IsHoliday(*args
, **kwargs
):
135 """IsHoliday(self) -> bool"""
136 return _calendar
.CalendarDateAttr_IsHoliday(*args
, **kwargs
)
138 def GetTextColour(*args
, **kwargs
):
139 """GetTextColour(self) -> Colour"""
140 return _calendar
.CalendarDateAttr_GetTextColour(*args
, **kwargs
)
142 def GetBackgroundColour(*args
, **kwargs
):
143 """GetBackgroundColour(self) -> Colour"""
144 return _calendar
.CalendarDateAttr_GetBackgroundColour(*args
, **kwargs
)
146 def GetBorderColour(*args
, **kwargs
):
147 """GetBorderColour(self) -> Colour"""
148 return _calendar
.CalendarDateAttr_GetBorderColour(*args
, **kwargs
)
150 def GetFont(*args
, **kwargs
):
151 """GetFont(self) -> Font"""
152 return _calendar
.CalendarDateAttr_GetFont(*args
, **kwargs
)
154 def GetBorder(*args
, **kwargs
):
155 """GetBorder(self) -> int"""
156 return _calendar
.CalendarDateAttr_GetBorder(*args
, **kwargs
)
159 class CalendarDateAttrPtr(CalendarDateAttr
):
160 def __init__(self
, this
):
162 if not hasattr(self
,"thisown"): self
.thisown
= 0
163 self
.__class
__ = CalendarDateAttr
164 _calendar
.CalendarDateAttr_swigregister(CalendarDateAttrPtr
)
166 class CalendarEvent(_core
.DateEvent
):
167 """Proxy of C++ CalendarEvent class"""
169 return "<%s.%s; proxy of C++ wxCalendarEvent instance at %s>" % (self
.__class
__.__module
__, self
.__class
__.__name
__, self
.this
,)
170 def __init__(self
, *args
, **kwargs
):
171 """__init__(self, CalendarCtrl cal, wxEventType type) -> CalendarEvent"""
172 newobj
= _calendar
.new_CalendarEvent(*args
, **kwargs
)
173 self
.this
= newobj
.this
176 def SetWeekDay(*args
, **kwargs
):
177 """SetWeekDay(self, int wd)"""
178 return _calendar
.CalendarEvent_SetWeekDay(*args
, **kwargs
)
180 def GetWeekDay(*args
, **kwargs
):
181 """GetWeekDay(self) -> int"""
182 return _calendar
.CalendarEvent_GetWeekDay(*args
, **kwargs
)
184 def PySetDate(self
, date
):
185 """takes datetime.datetime or datetime.date object"""
186 self
.SetDate(_pydate2wxdate(date
))
189 """returns datetime.date object"""
190 return _wxdate2pydate(self
.GetDate())
193 class CalendarEventPtr(CalendarEvent
):
194 def __init__(self
, this
):
196 if not hasattr(self
,"thisown"): self
.thisown
= 0
197 self
.__class
__ = CalendarEvent
198 _calendar
.CalendarEvent_swigregister(CalendarEventPtr
)
200 wxEVT_CALENDAR_DOUBLECLICKED
= _calendar
.wxEVT_CALENDAR_DOUBLECLICKED
201 wxEVT_CALENDAR_SEL_CHANGED
= _calendar
.wxEVT_CALENDAR_SEL_CHANGED
202 wxEVT_CALENDAR_DAY_CHANGED
= _calendar
.wxEVT_CALENDAR_DAY_CHANGED
203 wxEVT_CALENDAR_MONTH_CHANGED
= _calendar
.wxEVT_CALENDAR_MONTH_CHANGED
204 wxEVT_CALENDAR_YEAR_CHANGED
= _calendar
.wxEVT_CALENDAR_YEAR_CHANGED
205 wxEVT_CALENDAR_WEEKDAY_CLICKED
= _calendar
.wxEVT_CALENDAR_WEEKDAY_CLICKED
206 EVT_CALENDAR
= wx
.PyEventBinder( wxEVT_CALENDAR_DOUBLECLICKED
, 1)
207 EVT_CALENDAR_SEL_CHANGED
= wx
.PyEventBinder( wxEVT_CALENDAR_SEL_CHANGED
, 1)
208 EVT_CALENDAR_DAY
= wx
.PyEventBinder( wxEVT_CALENDAR_DAY_CHANGED
, 1)
209 EVT_CALENDAR_MONTH
= wx
.PyEventBinder( wxEVT_CALENDAR_MONTH_CHANGED
, 1)
210 EVT_CALENDAR_YEAR
= wx
.PyEventBinder( wxEVT_CALENDAR_YEAR_CHANGED
, 1)
211 EVT_CALENDAR_WEEKDAY_CLICKED
= wx
.PyEventBinder( wxEVT_CALENDAR_WEEKDAY_CLICKED
, 1)
213 class CalendarCtrl(_core
.Control
):
215 The calendar control allows the user to pick a date interactively.
217 The CalendarCtrl displays a window containing several parts: the
218 control to pick the month and the year at the top (either or both of
219 them may be disabled) and a month area below them which shows all the
220 days in the month. The user can move the current selection using the
221 keyboard and select the date (generating EVT_CALENDAR event) by
222 pressing <Return> or double clicking it.
224 It has advanced possibilities for the customization of its
225 display. All global settings (such as colours and fonts used) can, of
226 course, be changed. But also, the display style for each day in the
227 month can be set independently using CalendarDateAttr class.
229 An item without custom attributes is drawn with the default colours
230 and font and without border, but setting custom attributes with
231 SetAttr allows to modify its appearance. Just create a custom
232 attribute object and set it for the day you want to be displayed
233 specially A day may be marked as being a holiday, (even if it is not
234 recognized as one by `wx.DateTime`) by using the SetHoliday method.
236 As the attributes are specified for each day, they may change when the
237 month is changed, so you will often want to update them in an
238 EVT_CALENDAR_MONTH event handler.
241 return "<%s.%s; proxy of C++ wxCalendarCtrl instance at %s>" % (self
.__class
__.__module
__, self
.__class
__.__name
__, self
.this
,)
242 def __init__(self
, *args
, **kwargs
):
244 __init__(self, Window parent, int id=-1, DateTime date=DefaultDateTime,
245 Point pos=DefaultPosition, Size size=DefaultSize,
246 long style=wxCAL_SHOW_HOLIDAYS|wxWANTS_CHARS,
247 String name=CalendarNameStr) -> CalendarCtrl
249 Create and show a calendar control.
251 newobj
= _calendar
.new_CalendarCtrl(*args
, **kwargs
)
252 self
.this
= newobj
.this
255 self
._setOORInfo
(self
)
257 def Create(*args
, **kwargs
):
259 Create(self, Window parent, int id, DateTime date=DefaultDateTime,
260 Point pos=DefaultPosition, Size size=DefaultSize,
261 long style=wxCAL_SHOW_HOLIDAYS|wxWANTS_CHARS,
262 String name=CalendarNameStr) -> bool
264 Acutally create the GUI portion of the CalendarCtrl for 2-phase
267 return _calendar
.CalendarCtrl_Create(*args
, **kwargs
)
269 def SetDate(*args
, **kwargs
):
271 SetDate(self, DateTime date)
273 Sets the current date.
275 return _calendar
.CalendarCtrl_SetDate(*args
, **kwargs
)
277 def GetDate(*args
, **kwargs
):
279 GetDate(self) -> DateTime
281 Gets the currently selected date.
283 return _calendar
.CalendarCtrl_GetDate(*args
, **kwargs
)
285 def SetLowerDateLimit(*args
, **kwargs
):
287 SetLowerDateLimit(self, DateTime date=DefaultDateTime) -> bool
289 set the range in which selection can occur
291 return _calendar
.CalendarCtrl_SetLowerDateLimit(*args
, **kwargs
)
293 def SetUpperDateLimit(*args
, **kwargs
):
295 SetUpperDateLimit(self, DateTime date=DefaultDateTime) -> bool
297 set the range in which selection can occur
299 return _calendar
.CalendarCtrl_SetUpperDateLimit(*args
, **kwargs
)
301 def GetLowerDateLimit(*args
, **kwargs
):
303 GetLowerDateLimit(self) -> DateTime
305 get the range in which selection can occur
307 return _calendar
.CalendarCtrl_GetLowerDateLimit(*args
, **kwargs
)
309 def GetUpperDateLimit(*args
, **kwargs
):
311 GetUpperDateLimit(self) -> DateTime
313 get the range in which selection can occur
315 return _calendar
.CalendarCtrl_GetUpperDateLimit(*args
, **kwargs
)
317 def SetDateRange(*args
, **kwargs
):
319 SetDateRange(self, DateTime lowerdate=DefaultDateTime, DateTime upperdate=DefaultDateTime) -> bool
321 set the range in which selection can occur
323 return _calendar
.CalendarCtrl_SetDateRange(*args
, **kwargs
)
325 def EnableYearChange(*args
, **kwargs
):
327 EnableYearChange(self, bool enable=True)
329 This function should be used instead of changing CAL_NO_YEAR_CHANGE
330 style bit directly. It allows or disallows the user to change the year
333 return _calendar
.CalendarCtrl_EnableYearChange(*args
, **kwargs
)
335 def EnableMonthChange(*args
, **kwargs
):
337 EnableMonthChange(self, bool enable=True)
339 This function should be used instead of changing CAL_NO_MONTH_CHANGE
340 style bit. It allows or disallows the user to change the month
341 interactively. Note that if the month can not be changed, the year can
342 not be changed either.
344 return _calendar
.CalendarCtrl_EnableMonthChange(*args
, **kwargs
)
346 def EnableHolidayDisplay(*args
, **kwargs
):
348 EnableHolidayDisplay(self, bool display=True)
350 This function should be used instead of changing CAL_SHOW_HOLIDAYS
351 style bit directly. It enables or disables the special highlighting of
354 return _calendar
.CalendarCtrl_EnableHolidayDisplay(*args
, **kwargs
)
356 def SetHeaderColours(*args
, **kwargs
):
358 SetHeaderColours(self, Colour colFg, Colour colBg)
360 Header colours are used for painting the weekdays at the top.
362 return _calendar
.CalendarCtrl_SetHeaderColours(*args
, **kwargs
)
364 def GetHeaderColourFg(*args
, **kwargs
):
366 GetHeaderColourFg(self) -> Colour
368 Header colours are used for painting the weekdays at the top.
370 return _calendar
.CalendarCtrl_GetHeaderColourFg(*args
, **kwargs
)
372 def GetHeaderColourBg(*args
, **kwargs
):
374 GetHeaderColourBg(self) -> Colour
376 Header colours are used for painting the weekdays at the top.
378 return _calendar
.CalendarCtrl_GetHeaderColourBg(*args
, **kwargs
)
380 def SetHighlightColours(*args
, **kwargs
):
382 SetHighlightColours(self, Colour colFg, Colour colBg)
384 Highlight colour is used for the currently selected date.
386 return _calendar
.CalendarCtrl_SetHighlightColours(*args
, **kwargs
)
388 def GetHighlightColourFg(*args
, **kwargs
):
390 GetHighlightColourFg(self) -> Colour
392 Highlight colour is used for the currently selected date.
394 return _calendar
.CalendarCtrl_GetHighlightColourFg(*args
, **kwargs
)
396 def GetHighlightColourBg(*args
, **kwargs
):
398 GetHighlightColourBg(self) -> Colour
400 Highlight colour is used for the currently selected date.
402 return _calendar
.CalendarCtrl_GetHighlightColourBg(*args
, **kwargs
)
404 def SetHolidayColours(*args
, **kwargs
):
406 SetHolidayColours(self, Colour colFg, Colour colBg)
408 Holiday colour is used for the holidays (if CAL_SHOW_HOLIDAYS style is
411 return _calendar
.CalendarCtrl_SetHolidayColours(*args
, **kwargs
)
413 def GetHolidayColourFg(*args
, **kwargs
):
415 GetHolidayColourFg(self) -> Colour
417 Holiday colour is used for the holidays (if CAL_SHOW_HOLIDAYS style is
420 return _calendar
.CalendarCtrl_GetHolidayColourFg(*args
, **kwargs
)
422 def GetHolidayColourBg(*args
, **kwargs
):
424 GetHolidayColourBg(self) -> Colour
426 Holiday colour is used for the holidays (if CAL_SHOW_HOLIDAYS style is
429 return _calendar
.CalendarCtrl_GetHolidayColourBg(*args
, **kwargs
)
431 def GetAttr(*args
, **kwargs
):
433 GetAttr(self, size_t day) -> CalendarDateAttr
435 Returns the attribute for the given date (should be in the range
436 1...31). The returned value may be None
438 return _calendar
.CalendarCtrl_GetAttr(*args
, **kwargs
)
440 def SetAttr(*args
, **kwargs
):
442 SetAttr(self, size_t day, CalendarDateAttr attr)
444 Associates the attribute with the specified date (in the range
445 1...31). If the attribute passed is None, the items attribute is
448 return _calendar
.CalendarCtrl_SetAttr(*args
, **kwargs
)
450 def SetHoliday(*args
, **kwargs
):
452 SetHoliday(self, size_t day)
454 Marks the specified day as being a holiday in the current month.
456 return _calendar
.CalendarCtrl_SetHoliday(*args
, **kwargs
)
458 def ResetAttr(*args
, **kwargs
):
460 ResetAttr(self, size_t day)
462 Clears any attributes associated with the given day (in the range
465 return _calendar
.CalendarCtrl_ResetAttr(*args
, **kwargs
)
467 def HitTest(*args
, **kwargs
):
469 HitTest(Point pos) -> (result, date, weekday)
471 Returns 3-tuple with information about the given position on the
472 calendar control. The first value of the tuple is a result code and
473 determines the validity of the remaining two values.
475 return _calendar
.CalendarCtrl_HitTest(*args
, **kwargs
)
477 def GetMonthControl(*args
, **kwargs
):
479 GetMonthControl(self) -> Control
481 Get the currently shown control for month.
483 return _calendar
.CalendarCtrl_GetMonthControl(*args
, **kwargs
)
485 def GetYearControl(*args
, **kwargs
):
487 GetYearControl(self) -> Control
489 Get the currently shown control for year.
491 return _calendar
.CalendarCtrl_GetYearControl(*args
, **kwargs
)
493 def GetClassDefaultAttributes(*args
, **kwargs
):
495 GetClassDefaultAttributes(int variant=WINDOW_VARIANT_NORMAL) -> VisualAttributes
497 Get the default attributes for this class. This is useful if you want
498 to use the same font or colour in your own control as in a standard
499 control -- which is a much better idea than hard coding specific
500 colours or fonts which might look completely out of place on the
501 user's system, especially if it uses themes.
503 The variant parameter is only relevant under Mac currently and is
504 ignore under other platforms. Under Mac, it will change the size of
505 the returned font. See `wx.Window.SetWindowVariant` for more about
508 return _calendar
.CalendarCtrl_GetClassDefaultAttributes(*args
, **kwargs
)
510 GetClassDefaultAttributes
= staticmethod(GetClassDefaultAttributes
)
511 def PySetDate(self
, date
):
512 """takes datetime.datetime or datetime.date object"""
513 self
.SetDate(_pydate2wxdate(date
))
516 """returns datetime.date object"""
517 return _wxdate2pydate(self
.GetDate())
519 def PySetLowerDateLimit(self
, date
):
520 """takes datetime.datetime or datetime.date object"""
521 self
.SetLowerDateLimit(_pydate2wxdate(date
))
523 def PySetUpperDateLimit(self
, date
):
524 """takes datetime.datetime or datetime.date object"""
525 self
.SetUpperDateLimit(_pydate2wxdate(date
))
527 def PySetDateRange(self
, lowerdate
, upperdate
):
528 """takes datetime.datetime or datetime.date objects"""
529 self
.PySetLowerDateLimit(lowerdate
)
530 self
.PySetUpperDateLimit(upperdate
)
532 def PyGetLowerDateLimit(self
):
533 """returns datetime.date object"""
534 return _wxdate2pydate(self
.GetLowerDateLimit())
536 def PyGetUpperDateLimit(self
):
537 """returns datetime.date object"""
538 return _wxdate2pydate(self
.GetUpperDateLimit())
541 class CalendarCtrlPtr(CalendarCtrl
):
542 def __init__(self
, this
):
544 if not hasattr(self
,"thisown"): self
.thisown
= 0
545 self
.__class
__ = CalendarCtrl
546 _calendar
.CalendarCtrl_swigregister(CalendarCtrlPtr
)
547 cvar
= _calendar
.cvar
548 CalendarNameStr
= cvar
.CalendarNameStr
550 def PreCalendarCtrl(*args
, **kwargs
):
552 PreCalendarCtrl() -> CalendarCtrl
554 Precreate a CalendarCtrl for 2-phase creation.
556 val
= _calendar
.new_PreCalendarCtrl(*args
, **kwargs
)
560 def CalendarCtrl_GetClassDefaultAttributes(*args
, **kwargs
):
562 CalendarCtrl_GetClassDefaultAttributes(int variant=WINDOW_VARIANT_NORMAL) -> VisualAttributes
564 Get the default attributes for this class. This is useful if you want
565 to use the same font or colour in your own control as in a standard
566 control -- which is a much better idea than hard coding specific
567 colours or fonts which might look completely out of place on the
568 user's system, especially if it uses themes.
570 The variant parameter is only relevant under Mac currently and is
571 ignore under other platforms. Under Mac, it will change the size of
572 the returned font. See `wx.Window.SetWindowVariant` for more about
575 return _calendar
.CalendarCtrl_GetClassDefaultAttributes(*args
, **kwargs
)
577 def _pydate2wxdate(date
):
579 assert isinstance(date
, (datetime
.datetime
, datetime
.date
))
580 tt
= date
.timetuple()
581 dmy
= (tt
[2], tt
[1]-1, tt
[0])
582 return wx
.DateTimeFromDMY(*dmy
)
584 def _wxdate2pydate(date
):
586 assert isinstance(date
, wx
.DateTime
)
588 ymd
= map(int, date
.FormatISODate().split('-'))
589 return datetime
.date(*ymd
)