1 # This file was created automatically by SWIG 1.3.29.
2 # Don't modify this file, modify the SWIG interface instead.
5 Classes for an interactive Calendar control.
10 new_instancemethod
= new
.instancemethod
11 def _swig_setattr_nondynamic(self
,class_type
,name
,value
,static
=1):
12 if (name
== "thisown"): return self
.this
.own(value
)
14 if type(value
).__name
__ == 'PySwigObject':
15 self
.__dict
__[name
] = value
17 method
= class_type
.__swig
_setmethods
__.get(name
,None)
18 if method
: return method(self
,value
)
19 if (not static
) or hasattr(self
,name
):
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 if (name
== "thisown"): return self
.this
.own()
29 method
= class_type
.__swig
_getmethods
__.get(name
,None)
30 if method
: return method(self
)
31 raise AttributeError,name
34 try: strthis
= "proxy of " + self
.this
.__repr
__()
36 return "<%s.%s; %s >" % (self
.__class
__.__module
__, self
.__class
__.__name
__, strthis
,)
40 _object
= types
.ObjectType
42 except AttributeError:
48 def _swig_setattr_nondynamic_method(set):
49 def set_attr(self
,name
,value
):
50 if (name
== "thisown"): return self
.this
.own(value
)
51 if hasattr(self
,name
) or (name
== "this"):
54 raise AttributeError("You cannot add attributes to %s" % self
)
61 __docfilter__
= wx
.__DocFilter
(globals())
62 CAL_SUNDAY_FIRST
= _calendar
.CAL_SUNDAY_FIRST
63 CAL_MONDAY_FIRST
= _calendar
.CAL_MONDAY_FIRST
64 CAL_SHOW_HOLIDAYS
= _calendar
.CAL_SHOW_HOLIDAYS
65 CAL_NO_YEAR_CHANGE
= _calendar
.CAL_NO_YEAR_CHANGE
66 CAL_NO_MONTH_CHANGE
= _calendar
.CAL_NO_MONTH_CHANGE
67 CAL_SEQUENTIAL_MONTH_SELECTION
= _calendar
.CAL_SEQUENTIAL_MONTH_SELECTION
68 CAL_SHOW_SURROUNDING_WEEKS
= _calendar
.CAL_SHOW_SURROUNDING_WEEKS
69 CAL_HITTEST_NOWHERE
= _calendar
.CAL_HITTEST_NOWHERE
70 CAL_HITTEST_HEADER
= _calendar
.CAL_HITTEST_HEADER
71 CAL_HITTEST_DAY
= _calendar
.CAL_HITTEST_DAY
72 CAL_HITTEST_INCMONTH
= _calendar
.CAL_HITTEST_INCMONTH
73 CAL_HITTEST_DECMONTH
= _calendar
.CAL_HITTEST_DECMONTH
74 CAL_HITTEST_SURROUNDING_WEEK
= _calendar
.CAL_HITTEST_SURROUNDING_WEEK
75 CAL_BORDER_NONE
= _calendar
.CAL_BORDER_NONE
76 CAL_BORDER_SQUARE
= _calendar
.CAL_BORDER_SQUARE
77 CAL_BORDER_ROUND
= _calendar
.CAL_BORDER_ROUND
78 class CalendarDateAttr(object):
80 A set of customization attributes for a calendar date, which can be
81 used to control the look of the Calendar object.
83 thisown
= property(lambda x
: x
.this
.own(), lambda x
, v
: x
.this
.own(v
), doc
='The membership flag')
85 def __init__(self
, *args
, **kwargs
):
87 __init__(self, Colour colText=wxNullColour, Colour colBack=wxNullColour,
88 Colour colBorder=wxNullColour, Font font=wxNullFont,
89 int border=CAL_BORDER_NONE) -> CalendarDateAttr
91 Create a CalendarDateAttr.
93 _calendar
.CalendarDateAttr_swiginit(self
,_calendar
.new_CalendarDateAttr(*args
, **kwargs
))
94 def SetTextColour(*args
, **kwargs
):
95 """SetTextColour(self, Colour colText)"""
96 return _calendar
.CalendarDateAttr_SetTextColour(*args
, **kwargs
)
98 def SetBackgroundColour(*args
, **kwargs
):
99 """SetBackgroundColour(self, Colour colBack)"""
100 return _calendar
.CalendarDateAttr_SetBackgroundColour(*args
, **kwargs
)
102 def SetBorderColour(*args
, **kwargs
):
103 """SetBorderColour(self, Colour col)"""
104 return _calendar
.CalendarDateAttr_SetBorderColour(*args
, **kwargs
)
106 def SetFont(*args
, **kwargs
):
107 """SetFont(self, Font font)"""
108 return _calendar
.CalendarDateAttr_SetFont(*args
, **kwargs
)
110 def SetBorder(*args
, **kwargs
):
111 """SetBorder(self, int border)"""
112 return _calendar
.CalendarDateAttr_SetBorder(*args
, **kwargs
)
114 def SetHoliday(*args
, **kwargs
):
115 """SetHoliday(self, bool holiday)"""
116 return _calendar
.CalendarDateAttr_SetHoliday(*args
, **kwargs
)
118 def HasTextColour(*args
, **kwargs
):
119 """HasTextColour(self) -> bool"""
120 return _calendar
.CalendarDateAttr_HasTextColour(*args
, **kwargs
)
122 def HasBackgroundColour(*args
, **kwargs
):
123 """HasBackgroundColour(self) -> bool"""
124 return _calendar
.CalendarDateAttr_HasBackgroundColour(*args
, **kwargs
)
126 def HasBorderColour(*args
, **kwargs
):
127 """HasBorderColour(self) -> bool"""
128 return _calendar
.CalendarDateAttr_HasBorderColour(*args
, **kwargs
)
130 def HasFont(*args
, **kwargs
):
131 """HasFont(self) -> bool"""
132 return _calendar
.CalendarDateAttr_HasFont(*args
, **kwargs
)
134 def HasBorder(*args
, **kwargs
):
135 """HasBorder(self) -> bool"""
136 return _calendar
.CalendarDateAttr_HasBorder(*args
, **kwargs
)
138 def IsHoliday(*args
, **kwargs
):
139 """IsHoliday(self) -> bool"""
140 return _calendar
.CalendarDateAttr_IsHoliday(*args
, **kwargs
)
142 def GetTextColour(*args
, **kwargs
):
143 """GetTextColour(self) -> Colour"""
144 return _calendar
.CalendarDateAttr_GetTextColour(*args
, **kwargs
)
146 def GetBackgroundColour(*args
, **kwargs
):
147 """GetBackgroundColour(self) -> Colour"""
148 return _calendar
.CalendarDateAttr_GetBackgroundColour(*args
, **kwargs
)
150 def GetBorderColour(*args
, **kwargs
):
151 """GetBorderColour(self) -> Colour"""
152 return _calendar
.CalendarDateAttr_GetBorderColour(*args
, **kwargs
)
154 def GetFont(*args
, **kwargs
):
155 """GetFont(self) -> Font"""
156 return _calendar
.CalendarDateAttr_GetFont(*args
, **kwargs
)
158 def GetBorder(*args
, **kwargs
):
159 """GetBorder(self) -> int"""
160 return _calendar
.CalendarDateAttr_GetBorder(*args
, **kwargs
)
162 _calendar
.CalendarDateAttr_swigregister(CalendarDateAttr
)
164 class CalendarEvent(_core
.DateEvent
):
165 """Proxy of C++ CalendarEvent class"""
166 thisown
= property(lambda x
: x
.this
.own(), lambda x
, v
: x
.this
.own(v
), doc
='The membership flag')
167 __repr__
= _swig_repr
168 def __init__(self
, *args
, **kwargs
):
169 """__init__(self, CalendarCtrl cal, EventType type) -> CalendarEvent"""
170 _calendar
.CalendarEvent_swiginit(self
,_calendar
.new_CalendarEvent(*args
, **kwargs
))
171 def SetWeekDay(*args
, **kwargs
):
172 """SetWeekDay(self, int wd)"""
173 return _calendar
.CalendarEvent_SetWeekDay(*args
, **kwargs
)
175 def GetWeekDay(*args
, **kwargs
):
176 """GetWeekDay(self) -> int"""
177 return _calendar
.CalendarEvent_GetWeekDay(*args
, **kwargs
)
179 def PySetDate(self
, date
):
180 """takes datetime.datetime or datetime.date object"""
181 self
.SetDate(_pydate2wxdate(date
))
184 """returns datetime.date object"""
185 return _wxdate2pydate(self
.GetDate())
187 _calendar
.CalendarEvent_swigregister(CalendarEvent
)
189 wxEVT_CALENDAR_DOUBLECLICKED
= _calendar
.wxEVT_CALENDAR_DOUBLECLICKED
190 wxEVT_CALENDAR_SEL_CHANGED
= _calendar
.wxEVT_CALENDAR_SEL_CHANGED
191 wxEVT_CALENDAR_DAY_CHANGED
= _calendar
.wxEVT_CALENDAR_DAY_CHANGED
192 wxEVT_CALENDAR_MONTH_CHANGED
= _calendar
.wxEVT_CALENDAR_MONTH_CHANGED
193 wxEVT_CALENDAR_YEAR_CHANGED
= _calendar
.wxEVT_CALENDAR_YEAR_CHANGED
194 wxEVT_CALENDAR_WEEKDAY_CLICKED
= _calendar
.wxEVT_CALENDAR_WEEKDAY_CLICKED
195 EVT_CALENDAR
= wx
.PyEventBinder( wxEVT_CALENDAR_DOUBLECLICKED
, 1)
196 EVT_CALENDAR_SEL_CHANGED
= wx
.PyEventBinder( wxEVT_CALENDAR_SEL_CHANGED
, 1)
197 EVT_CALENDAR_DAY
= wx
.PyEventBinder( wxEVT_CALENDAR_DAY_CHANGED
, 1)
198 EVT_CALENDAR_MONTH
= wx
.PyEventBinder( wxEVT_CALENDAR_MONTH_CHANGED
, 1)
199 EVT_CALENDAR_YEAR
= wx
.PyEventBinder( wxEVT_CALENDAR_YEAR_CHANGED
, 1)
200 EVT_CALENDAR_WEEKDAY_CLICKED
= wx
.PyEventBinder( wxEVT_CALENDAR_WEEKDAY_CLICKED
, 1)
202 class CalendarCtrl(_core
.Control
):
204 The calendar control allows the user to pick a date interactively.
206 The CalendarCtrl displays a window containing several parts: the
207 control to pick the month and the year at the top (either or both of
208 them may be disabled) and a month area below them which shows all the
209 days in the month. The user can move the current selection using the
210 keyboard and select the date (generating EVT_CALENDAR event) by
211 pressing <Return> or double clicking it.
213 It has advanced possibilities for the customization of its
214 display. All global settings (such as colours and fonts used) can, of
215 course, be changed. But also, the display style for each day in the
216 month can be set independently using CalendarDateAttr class.
218 An item without custom attributes is drawn with the default colours
219 and font and without border, but setting custom attributes with
220 SetAttr allows to modify its appearance. Just create a custom
221 attribute object and set it for the day you want to be displayed
222 specially A day may be marked as being a holiday, (even if it is not
223 recognized as one by `wx.DateTime`) by using the SetHoliday method.
225 As the attributes are specified for each day, they may change when the
226 month is changed, so you will often want to update them in an
227 EVT_CALENDAR_MONTH event handler.
229 thisown
= property(lambda x
: x
.this
.own(), lambda x
, v
: x
.this
.own(v
), doc
='The membership flag')
230 __repr__
= _swig_repr
231 def __init__(self
, *args
, **kwargs
):
233 __init__(self, Window parent, int id=-1, DateTime date=DefaultDateTime,
234 Point pos=DefaultPosition, Size size=DefaultSize,
235 long style=wxCAL_SHOW_HOLIDAYS|wxWANTS_CHARS,
236 String name=CalendarNameStr) -> CalendarCtrl
238 Create and show a calendar control.
240 _calendar
.CalendarCtrl_swiginit(self
,_calendar
.new_CalendarCtrl(*args
, **kwargs
))
241 self
._setOORInfo
(self
)
243 def Create(*args
, **kwargs
):
245 Create(self, Window parent, int id, DateTime date=DefaultDateTime,
246 Point pos=DefaultPosition, Size size=DefaultSize,
247 long style=wxCAL_SHOW_HOLIDAYS|wxWANTS_CHARS,
248 String name=CalendarNameStr) -> bool
250 Acutally create the GUI portion of the CalendarCtrl for 2-phase
253 return _calendar
.CalendarCtrl_Create(*args
, **kwargs
)
255 def SetDate(*args
, **kwargs
):
257 SetDate(self, DateTime date)
259 Sets the current date.
261 return _calendar
.CalendarCtrl_SetDate(*args
, **kwargs
)
263 def GetDate(*args
, **kwargs
):
265 GetDate(self) -> DateTime
267 Gets the currently selected date.
269 return _calendar
.CalendarCtrl_GetDate(*args
, **kwargs
)
271 def SetLowerDateLimit(*args
, **kwargs
):
273 SetLowerDateLimit(self, DateTime date=DefaultDateTime) -> bool
275 set the range in which selection can occur
277 return _calendar
.CalendarCtrl_SetLowerDateLimit(*args
, **kwargs
)
279 def SetUpperDateLimit(*args
, **kwargs
):
281 SetUpperDateLimit(self, DateTime date=DefaultDateTime) -> bool
283 set the range in which selection can occur
285 return _calendar
.CalendarCtrl_SetUpperDateLimit(*args
, **kwargs
)
287 def GetLowerDateLimit(*args
, **kwargs
):
289 GetLowerDateLimit(self) -> DateTime
291 get the range in which selection can occur
293 return _calendar
.CalendarCtrl_GetLowerDateLimit(*args
, **kwargs
)
295 def GetUpperDateLimit(*args
, **kwargs
):
297 GetUpperDateLimit(self) -> DateTime
299 get the range in which selection can occur
301 return _calendar
.CalendarCtrl_GetUpperDateLimit(*args
, **kwargs
)
303 def SetDateRange(*args
, **kwargs
):
305 SetDateRange(self, DateTime lowerdate=DefaultDateTime, DateTime upperdate=DefaultDateTime) -> bool
307 set the range in which selection can occur
309 return _calendar
.CalendarCtrl_SetDateRange(*args
, **kwargs
)
311 def EnableYearChange(*args
, **kwargs
):
313 EnableYearChange(self, bool enable=True)
315 This function should be used instead of changing CAL_NO_YEAR_CHANGE
316 style bit directly. It allows or disallows the user to change the year
319 return _calendar
.CalendarCtrl_EnableYearChange(*args
, **kwargs
)
321 def EnableMonthChange(*args
, **kwargs
):
323 EnableMonthChange(self, bool enable=True)
325 This function should be used instead of changing CAL_NO_MONTH_CHANGE
326 style bit. It allows or disallows the user to change the month
327 interactively. Note that if the month can not be changed, the year can
328 not be changed either.
330 return _calendar
.CalendarCtrl_EnableMonthChange(*args
, **kwargs
)
332 def EnableHolidayDisplay(*args
, **kwargs
):
334 EnableHolidayDisplay(self, bool display=True)
336 This function should be used instead of changing CAL_SHOW_HOLIDAYS
337 style bit directly. It enables or disables the special highlighting of
340 return _calendar
.CalendarCtrl_EnableHolidayDisplay(*args
, **kwargs
)
342 def SetHeaderColours(*args
, **kwargs
):
344 SetHeaderColours(self, Colour colFg, Colour colBg)
346 Header colours are used for painting the weekdays at the top.
348 return _calendar
.CalendarCtrl_SetHeaderColours(*args
, **kwargs
)
350 def GetHeaderColourFg(*args
, **kwargs
):
352 GetHeaderColourFg(self) -> Colour
354 Header colours are used for painting the weekdays at the top.
356 return _calendar
.CalendarCtrl_GetHeaderColourFg(*args
, **kwargs
)
358 def GetHeaderColourBg(*args
, **kwargs
):
360 GetHeaderColourBg(self) -> Colour
362 Header colours are used for painting the weekdays at the top.
364 return _calendar
.CalendarCtrl_GetHeaderColourBg(*args
, **kwargs
)
366 def SetHighlightColours(*args
, **kwargs
):
368 SetHighlightColours(self, Colour colFg, Colour colBg)
370 Highlight colour is used for the currently selected date.
372 return _calendar
.CalendarCtrl_SetHighlightColours(*args
, **kwargs
)
374 def GetHighlightColourFg(*args
, **kwargs
):
376 GetHighlightColourFg(self) -> Colour
378 Highlight colour is used for the currently selected date.
380 return _calendar
.CalendarCtrl_GetHighlightColourFg(*args
, **kwargs
)
382 def GetHighlightColourBg(*args
, **kwargs
):
384 GetHighlightColourBg(self) -> Colour
386 Highlight colour is used for the currently selected date.
388 return _calendar
.CalendarCtrl_GetHighlightColourBg(*args
, **kwargs
)
390 def SetHolidayColours(*args
, **kwargs
):
392 SetHolidayColours(self, Colour colFg, Colour colBg)
394 Holiday colour is used for the holidays (if CAL_SHOW_HOLIDAYS style is
397 return _calendar
.CalendarCtrl_SetHolidayColours(*args
, **kwargs
)
399 def GetHolidayColourFg(*args
, **kwargs
):
401 GetHolidayColourFg(self) -> Colour
403 Holiday colour is used for the holidays (if CAL_SHOW_HOLIDAYS style is
406 return _calendar
.CalendarCtrl_GetHolidayColourFg(*args
, **kwargs
)
408 def GetHolidayColourBg(*args
, **kwargs
):
410 GetHolidayColourBg(self) -> Colour
412 Holiday colour is used for the holidays (if CAL_SHOW_HOLIDAYS style is
415 return _calendar
.CalendarCtrl_GetHolidayColourBg(*args
, **kwargs
)
417 def GetAttr(*args
, **kwargs
):
419 GetAttr(self, size_t day) -> CalendarDateAttr
421 Returns the attribute for the given date (should be in the range
422 1...31). The returned value may be None
424 return _calendar
.CalendarCtrl_GetAttr(*args
, **kwargs
)
426 def SetAttr(*args
, **kwargs
):
428 SetAttr(self, size_t day, CalendarDateAttr attr)
430 Associates the attribute with the specified date (in the range
431 1...31). If the attribute passed is None, the items attribute is
434 return _calendar
.CalendarCtrl_SetAttr(*args
, **kwargs
)
436 def SetHoliday(*args
, **kwargs
):
438 SetHoliday(self, size_t day)
440 Marks the specified day as being a holiday in the current month.
442 return _calendar
.CalendarCtrl_SetHoliday(*args
, **kwargs
)
444 def ResetAttr(*args
, **kwargs
):
446 ResetAttr(self, size_t day)
448 Clears any attributes associated with the given day (in the range
451 return _calendar
.CalendarCtrl_ResetAttr(*args
, **kwargs
)
453 def HitTest(*args
, **kwargs
):
455 HitTest(Point pos) -> (result, date, weekday)
457 Returns 3-tuple with information about the given position on the
458 calendar control. The first value of the tuple is a result code and
459 determines the validity of the remaining two values.
461 return _calendar
.CalendarCtrl_HitTest(*args
, **kwargs
)
463 def GetMonthControl(*args
, **kwargs
):
465 GetMonthControl(self) -> Control
467 Get the currently shown control for month.
469 return _calendar
.CalendarCtrl_GetMonthControl(*args
, **kwargs
)
471 def GetYearControl(*args
, **kwargs
):
473 GetYearControl(self) -> Control
475 Get the currently shown control for year.
477 return _calendar
.CalendarCtrl_GetYearControl(*args
, **kwargs
)
479 def GetClassDefaultAttributes(*args
, **kwargs
):
481 GetClassDefaultAttributes(int variant=WINDOW_VARIANT_NORMAL) -> VisualAttributes
483 Get the default attributes for this class. This is useful if you want
484 to use the same font or colour in your own control as in a standard
485 control -- which is a much better idea than hard coding specific
486 colours or fonts which might look completely out of place on the
487 user's system, especially if it uses themes.
489 The variant parameter is only relevant under Mac currently and is
490 ignore under other platforms. Under Mac, it will change the size of
491 the returned font. See `wx.Window.SetWindowVariant` for more about
494 return _calendar
.CalendarCtrl_GetClassDefaultAttributes(*args
, **kwargs
)
496 GetClassDefaultAttributes
= staticmethod(GetClassDefaultAttributes
)
497 def PySetDate(self
, date
):
498 """takes datetime.datetime or datetime.date object"""
499 self
.SetDate(_pydate2wxdate(date
))
502 """returns datetime.date object"""
503 return _wxdate2pydate(self
.GetDate())
505 def PySetLowerDateLimit(self
, date
):
506 """takes datetime.datetime or datetime.date object"""
507 self
.SetLowerDateLimit(_pydate2wxdate(date
))
509 def PySetUpperDateLimit(self
, date
):
510 """takes datetime.datetime or datetime.date object"""
511 self
.SetUpperDateLimit(_pydate2wxdate(date
))
513 def PySetDateRange(self
, lowerdate
, upperdate
):
514 """takes datetime.datetime or datetime.date objects"""
515 self
.PySetLowerDateLimit(lowerdate
)
516 self
.PySetUpperDateLimit(upperdate
)
518 def PyGetLowerDateLimit(self
):
519 """returns datetime.date object"""
520 return _wxdate2pydate(self
.GetLowerDateLimit())
522 def PyGetUpperDateLimit(self
):
523 """returns datetime.date object"""
524 return _wxdate2pydate(self
.GetUpperDateLimit())
526 _calendar
.CalendarCtrl_swigregister(CalendarCtrl
)
527 cvar
= _calendar
.cvar
528 CalendarNameStr
= cvar
.CalendarNameStr
530 def PreCalendarCtrl(*args
, **kwargs
):
532 PreCalendarCtrl() -> CalendarCtrl
534 Precreate a CalendarCtrl for 2-phase creation.
536 val
= _calendar
.new_PreCalendarCtrl(*args
, **kwargs
)
539 def CalendarCtrl_GetClassDefaultAttributes(*args
, **kwargs
):
541 CalendarCtrl_GetClassDefaultAttributes(int variant=WINDOW_VARIANT_NORMAL) -> VisualAttributes
543 Get the default attributes for this class. This is useful if you want
544 to use the same font or colour in your own control as in a standard
545 control -- which is a much better idea than hard coding specific
546 colours or fonts which might look completely out of place on the
547 user's system, especially if it uses themes.
549 The variant parameter is only relevant under Mac currently and is
550 ignore under other platforms. Under Mac, it will change the size of
551 the returned font. See `wx.Window.SetWindowVariant` for more about
554 return _calendar
.CalendarCtrl_GetClassDefaultAttributes(*args
, **kwargs
)
556 def _pydate2wxdate(date
):
558 assert isinstance(date
, (datetime
.datetime
, datetime
.date
))
559 tt
= date
.timetuple()
560 dmy
= (tt
[2], tt
[1]-1, tt
[0])
561 return wx
.DateTimeFromDMY(*dmy
)
563 def _wxdate2pydate(date
):
565 assert isinstance(date
, wx
.DateTime
)
567 ymd
= map(int, date
.FormatISODate().split('-'))
568 return datetime
.date(*ymd
)