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 __swig_destroy__
= _calendar
.delete_CalendarDateAttr
95 __del__
= lambda self
: None;
96 def SetTextColour(*args
, **kwargs
):
97 """SetTextColour(self, Colour colText)"""
98 return _calendar
.CalendarDateAttr_SetTextColour(*args
, **kwargs
)
100 def SetBackgroundColour(*args
, **kwargs
):
101 """SetBackgroundColour(self, Colour colBack)"""
102 return _calendar
.CalendarDateAttr_SetBackgroundColour(*args
, **kwargs
)
104 def SetBorderColour(*args
, **kwargs
):
105 """SetBorderColour(self, Colour col)"""
106 return _calendar
.CalendarDateAttr_SetBorderColour(*args
, **kwargs
)
108 def SetFont(*args
, **kwargs
):
109 """SetFont(self, Font font)"""
110 return _calendar
.CalendarDateAttr_SetFont(*args
, **kwargs
)
112 def SetBorder(*args
, **kwargs
):
113 """SetBorder(self, int border)"""
114 return _calendar
.CalendarDateAttr_SetBorder(*args
, **kwargs
)
116 def SetHoliday(*args
, **kwargs
):
117 """SetHoliday(self, bool holiday)"""
118 return _calendar
.CalendarDateAttr_SetHoliday(*args
, **kwargs
)
120 def HasTextColour(*args
, **kwargs
):
121 """HasTextColour(self) -> bool"""
122 return _calendar
.CalendarDateAttr_HasTextColour(*args
, **kwargs
)
124 def HasBackgroundColour(*args
, **kwargs
):
125 """HasBackgroundColour(self) -> bool"""
126 return _calendar
.CalendarDateAttr_HasBackgroundColour(*args
, **kwargs
)
128 def HasBorderColour(*args
, **kwargs
):
129 """HasBorderColour(self) -> bool"""
130 return _calendar
.CalendarDateAttr_HasBorderColour(*args
, **kwargs
)
132 def HasFont(*args
, **kwargs
):
133 """HasFont(self) -> bool"""
134 return _calendar
.CalendarDateAttr_HasFont(*args
, **kwargs
)
136 def HasBorder(*args
, **kwargs
):
137 """HasBorder(self) -> bool"""
138 return _calendar
.CalendarDateAttr_HasBorder(*args
, **kwargs
)
140 def IsHoliday(*args
, **kwargs
):
141 """IsHoliday(self) -> bool"""
142 return _calendar
.CalendarDateAttr_IsHoliday(*args
, **kwargs
)
144 def GetTextColour(*args
, **kwargs
):
145 """GetTextColour(self) -> Colour"""
146 return _calendar
.CalendarDateAttr_GetTextColour(*args
, **kwargs
)
148 def GetBackgroundColour(*args
, **kwargs
):
149 """GetBackgroundColour(self) -> Colour"""
150 return _calendar
.CalendarDateAttr_GetBackgroundColour(*args
, **kwargs
)
152 def GetBorderColour(*args
, **kwargs
):
153 """GetBorderColour(self) -> Colour"""
154 return _calendar
.CalendarDateAttr_GetBorderColour(*args
, **kwargs
)
156 def GetFont(*args
, **kwargs
):
157 """GetFont(self) -> Font"""
158 return _calendar
.CalendarDateAttr_GetFont(*args
, **kwargs
)
160 def GetBorder(*args
, **kwargs
):
161 """GetBorder(self) -> int"""
162 return _calendar
.CalendarDateAttr_GetBorder(*args
, **kwargs
)
164 _calendar
.CalendarDateAttr_swigregister(CalendarDateAttr
)
166 class CalendarEvent(_core
.DateEvent
):
167 """Proxy of C++ CalendarEvent class"""
168 thisown
= property(lambda x
: x
.this
.own(), lambda x
, v
: x
.this
.own(v
), doc
='The membership flag')
169 __repr__
= _swig_repr
170 def __init__(self
, *args
, **kwargs
):
171 """__init__(self, CalendarCtrl cal, EventType type) -> CalendarEvent"""
172 _calendar
.CalendarEvent_swiginit(self
,_calendar
.new_CalendarEvent(*args
, **kwargs
))
173 def SetWeekDay(*args
, **kwargs
):
174 """SetWeekDay(self, int wd)"""
175 return _calendar
.CalendarEvent_SetWeekDay(*args
, **kwargs
)
177 def GetWeekDay(*args
, **kwargs
):
178 """GetWeekDay(self) -> int"""
179 return _calendar
.CalendarEvent_GetWeekDay(*args
, **kwargs
)
181 def PySetDate(self
, date
):
182 """takes datetime.datetime or datetime.date object"""
183 self
.SetDate(_pydate2wxdate(date
))
186 """returns datetime.date object"""
187 return _wxdate2pydate(self
.GetDate())
189 _calendar
.CalendarEvent_swigregister(CalendarEvent
)
191 wxEVT_CALENDAR_DOUBLECLICKED
= _calendar
.wxEVT_CALENDAR_DOUBLECLICKED
192 wxEVT_CALENDAR_SEL_CHANGED
= _calendar
.wxEVT_CALENDAR_SEL_CHANGED
193 wxEVT_CALENDAR_DAY_CHANGED
= _calendar
.wxEVT_CALENDAR_DAY_CHANGED
194 wxEVT_CALENDAR_MONTH_CHANGED
= _calendar
.wxEVT_CALENDAR_MONTH_CHANGED
195 wxEVT_CALENDAR_YEAR_CHANGED
= _calendar
.wxEVT_CALENDAR_YEAR_CHANGED
196 wxEVT_CALENDAR_WEEKDAY_CLICKED
= _calendar
.wxEVT_CALENDAR_WEEKDAY_CLICKED
197 EVT_CALENDAR
= wx
.PyEventBinder( wxEVT_CALENDAR_DOUBLECLICKED
, 1)
198 EVT_CALENDAR_SEL_CHANGED
= wx
.PyEventBinder( wxEVT_CALENDAR_SEL_CHANGED
, 1)
199 EVT_CALENDAR_DAY
= wx
.PyEventBinder( wxEVT_CALENDAR_DAY_CHANGED
, 1)
200 EVT_CALENDAR_MONTH
= wx
.PyEventBinder( wxEVT_CALENDAR_MONTH_CHANGED
, 1)
201 EVT_CALENDAR_YEAR
= wx
.PyEventBinder( wxEVT_CALENDAR_YEAR_CHANGED
, 1)
202 EVT_CALENDAR_WEEKDAY_CLICKED
= wx
.PyEventBinder( wxEVT_CALENDAR_WEEKDAY_CLICKED
, 1)
204 class CalendarCtrl(_core
.Control
):
206 The calendar control allows the user to pick a date interactively.
208 The CalendarCtrl displays a window containing several parts: the
209 control to pick the month and the year at the top (either or both of
210 them may be disabled) and a month area below them which shows all the
211 days in the month. The user can move the current selection using the
212 keyboard and select the date (generating EVT_CALENDAR event) by
213 pressing <Return> or double clicking it.
215 It has advanced possibilities for the customization of its
216 display. All global settings (such as colours and fonts used) can, of
217 course, be changed. But also, the display style for each day in the
218 month can be set independently using CalendarDateAttr class.
220 An item without custom attributes is drawn with the default colours
221 and font and without border, but setting custom attributes with
222 `SetAttr` allows to modify its appearance. Just create a custom
223 attribute object and set it for the day you want to be displayed
224 specially A day may be marked as being a holiday, (even if it is not
225 recognized as one by `wx.DateTime`) by using the SetHoliday method.
227 As the attributes are specified for each day, they may change when the
228 month is changed, so you will often want to update them in an
229 EVT_CALENDAR_MONTH event handler.
231 thisown
= property(lambda x
: x
.this
.own(), lambda x
, v
: x
.this
.own(v
), doc
='The membership flag')
232 __repr__
= _swig_repr
233 def __init__(self
, *args
, **kwargs
):
235 __init__(self, Window parent, int id=-1, DateTime date=DefaultDateTime,
236 Point pos=DefaultPosition, Size size=DefaultSize,
237 long style=wxCAL_SHOW_HOLIDAYS|wxWANTS_CHARS,
238 String name=CalendarNameStr) -> CalendarCtrl
240 Create and show a calendar control.
242 _calendar
.CalendarCtrl_swiginit(self
,_calendar
.new_CalendarCtrl(*args
, **kwargs
))
243 self
._setOORInfo
(self
)
245 def Create(*args
, **kwargs
):
247 Create(self, Window parent, int id, DateTime date=DefaultDateTime,
248 Point pos=DefaultPosition, Size size=DefaultSize,
249 long style=wxCAL_SHOW_HOLIDAYS|wxWANTS_CHARS,
250 String name=CalendarNameStr) -> bool
252 Acutally create the GUI portion of the CalendarCtrl for 2-phase
255 return _calendar
.CalendarCtrl_Create(*args
, **kwargs
)
257 def SetDate(*args
, **kwargs
):
259 SetDate(self, DateTime date)
261 Sets the current date.
263 return _calendar
.CalendarCtrl_SetDate(*args
, **kwargs
)
265 def GetDate(*args
, **kwargs
):
267 GetDate(self) -> DateTime
269 Gets the currently selected date.
271 return _calendar
.CalendarCtrl_GetDate(*args
, **kwargs
)
273 def SetLowerDateLimit(*args
, **kwargs
):
275 SetLowerDateLimit(self, DateTime date=DefaultDateTime) -> bool
277 set the range in which selection can occur
279 return _calendar
.CalendarCtrl_SetLowerDateLimit(*args
, **kwargs
)
281 def SetUpperDateLimit(*args
, **kwargs
):
283 SetUpperDateLimit(self, DateTime date=DefaultDateTime) -> bool
285 set the range in which selection can occur
287 return _calendar
.CalendarCtrl_SetUpperDateLimit(*args
, **kwargs
)
289 def GetLowerDateLimit(*args
, **kwargs
):
291 GetLowerDateLimit(self) -> DateTime
293 get the range in which selection can occur
295 return _calendar
.CalendarCtrl_GetLowerDateLimit(*args
, **kwargs
)
297 def GetUpperDateLimit(*args
, **kwargs
):
299 GetUpperDateLimit(self) -> DateTime
301 get the range in which selection can occur
303 return _calendar
.CalendarCtrl_GetUpperDateLimit(*args
, **kwargs
)
305 def SetDateRange(*args
, **kwargs
):
307 SetDateRange(self, DateTime lowerdate=DefaultDateTime, DateTime upperdate=DefaultDateTime) -> bool
309 set the range in which selection can occur
311 return _calendar
.CalendarCtrl_SetDateRange(*args
, **kwargs
)
313 def EnableYearChange(*args
, **kwargs
):
315 EnableYearChange(self, bool enable=True)
317 This function should be used instead of changing CAL_NO_YEAR_CHANGE
318 style bit directly. It allows or disallows the user to change the year
321 return _calendar
.CalendarCtrl_EnableYearChange(*args
, **kwargs
)
323 def EnableMonthChange(*args
, **kwargs
):
325 EnableMonthChange(self, bool enable=True)
327 This function should be used instead of changing CAL_NO_MONTH_CHANGE
328 style bit. It allows or disallows the user to change the month
329 interactively. Note that if the month can not be changed, the year can
330 not be changed either.
332 return _calendar
.CalendarCtrl_EnableMonthChange(*args
, **kwargs
)
334 def EnableHolidayDisplay(*args
, **kwargs
):
336 EnableHolidayDisplay(self, bool display=True)
338 This function should be used instead of changing CAL_SHOW_HOLIDAYS
339 style bit directly. It enables or disables the special highlighting of
342 return _calendar
.CalendarCtrl_EnableHolidayDisplay(*args
, **kwargs
)
344 def SetHeaderColours(*args
, **kwargs
):
346 SetHeaderColours(self, Colour colFg, Colour colBg)
348 Header colours are used for painting the weekdays at the top.
350 return _calendar
.CalendarCtrl_SetHeaderColours(*args
, **kwargs
)
352 def GetHeaderColourFg(*args
, **kwargs
):
354 GetHeaderColourFg(self) -> Colour
356 Header colours are used for painting the weekdays at the top.
358 return _calendar
.CalendarCtrl_GetHeaderColourFg(*args
, **kwargs
)
360 def GetHeaderColourBg(*args
, **kwargs
):
362 GetHeaderColourBg(self) -> Colour
364 Header colours are used for painting the weekdays at the top.
366 return _calendar
.CalendarCtrl_GetHeaderColourBg(*args
, **kwargs
)
368 def SetHighlightColours(*args
, **kwargs
):
370 SetHighlightColours(self, Colour colFg, Colour colBg)
372 Highlight colour is used for the currently selected date.
374 return _calendar
.CalendarCtrl_SetHighlightColours(*args
, **kwargs
)
376 def GetHighlightColourFg(*args
, **kwargs
):
378 GetHighlightColourFg(self) -> Colour
380 Highlight colour is used for the currently selected date.
382 return _calendar
.CalendarCtrl_GetHighlightColourFg(*args
, **kwargs
)
384 def GetHighlightColourBg(*args
, **kwargs
):
386 GetHighlightColourBg(self) -> Colour
388 Highlight colour is used for the currently selected date.
390 return _calendar
.CalendarCtrl_GetHighlightColourBg(*args
, **kwargs
)
392 def SetHolidayColours(*args
, **kwargs
):
394 SetHolidayColours(self, Colour colFg, Colour colBg)
396 Holiday colour is used for the holidays (if CAL_SHOW_HOLIDAYS style is
399 return _calendar
.CalendarCtrl_SetHolidayColours(*args
, **kwargs
)
401 def GetHolidayColourFg(*args
, **kwargs
):
403 GetHolidayColourFg(self) -> Colour
405 Holiday colour is used for the holidays (if CAL_SHOW_HOLIDAYS style is
408 return _calendar
.CalendarCtrl_GetHolidayColourFg(*args
, **kwargs
)
410 def GetHolidayColourBg(*args
, **kwargs
):
412 GetHolidayColourBg(self) -> Colour
414 Holiday colour is used for the holidays (if CAL_SHOW_HOLIDAYS style is
417 return _calendar
.CalendarCtrl_GetHolidayColourBg(*args
, **kwargs
)
419 def GetAttr(*args
, **kwargs
):
421 GetAttr(self, size_t day) -> CalendarDateAttr
423 Returns the attribute for the given date (should be in the range
424 1...31). The returned value may be None
426 return _calendar
.CalendarCtrl_GetAttr(*args
, **kwargs
)
428 def SetAttr(*args
, **kwargs
):
430 SetAttr(self, size_t day, CalendarDateAttr attr)
432 Associates the attribute with the specified date (in the range
433 1...31). If the attribute passed is None, the items attribute is
436 return _calendar
.CalendarCtrl_SetAttr(*args
, **kwargs
)
438 def SetHoliday(*args
, **kwargs
):
440 SetHoliday(self, size_t day)
442 Marks the specified day as being a holiday in the current month.
444 return _calendar
.CalendarCtrl_SetHoliday(*args
, **kwargs
)
446 def ResetAttr(*args
, **kwargs
):
448 ResetAttr(self, size_t day)
450 Clears any attributes associated with the given day (in the range
453 return _calendar
.CalendarCtrl_ResetAttr(*args
, **kwargs
)
455 def HitTest(*args
, **kwargs
):
457 HitTest(Point pos) -> (result, date, weekday)
459 Returns 3-tuple with information about the given position on the
460 calendar control. The first value of the tuple is a result code and
461 determines the validity of the remaining two values.
463 return _calendar
.CalendarCtrl_HitTest(*args
, **kwargs
)
465 def GetMonthControl(*args
, **kwargs
):
467 GetMonthControl(self) -> Control
469 Get the currently shown control for month.
471 return _calendar
.CalendarCtrl_GetMonthControl(*args
, **kwargs
)
473 def GetYearControl(*args
, **kwargs
):
475 GetYearControl(self) -> Control
477 Get the currently shown control for year.
479 return _calendar
.CalendarCtrl_GetYearControl(*args
, **kwargs
)
481 def GetClassDefaultAttributes(*args
, **kwargs
):
483 GetClassDefaultAttributes(int variant=WINDOW_VARIANT_NORMAL) -> VisualAttributes
485 Get the default attributes for this class. This is useful if you want
486 to use the same font or colour in your own control as in a standard
487 control -- which is a much better idea than hard coding specific
488 colours or fonts which might look completely out of place on the
489 user's system, especially if it uses themes.
491 The variant parameter is only relevant under Mac currently and is
492 ignore under other platforms. Under Mac, it will change the size of
493 the returned font. See `wx.Window.SetWindowVariant` for more about
496 return _calendar
.CalendarCtrl_GetClassDefaultAttributes(*args
, **kwargs
)
498 GetClassDefaultAttributes
= staticmethod(GetClassDefaultAttributes
)
499 def PySetDate(self
, date
):
500 """takes datetime.datetime or datetime.date object"""
501 self
.SetDate(_pydate2wxdate(date
))
504 """returns datetime.date object"""
505 return _wxdate2pydate(self
.GetDate())
507 def PySetLowerDateLimit(self
, date
):
508 """takes datetime.datetime or datetime.date object"""
509 self
.SetLowerDateLimit(_pydate2wxdate(date
))
511 def PySetUpperDateLimit(self
, date
):
512 """takes datetime.datetime or datetime.date object"""
513 self
.SetUpperDateLimit(_pydate2wxdate(date
))
515 def PySetDateRange(self
, lowerdate
, upperdate
):
516 """takes datetime.datetime or datetime.date objects"""
517 self
.PySetLowerDateLimit(lowerdate
)
518 self
.PySetUpperDateLimit(upperdate
)
520 def PyGetLowerDateLimit(self
):
521 """returns datetime.date object"""
522 return _wxdate2pydate(self
.GetLowerDateLimit())
524 def PyGetUpperDateLimit(self
):
525 """returns datetime.date object"""
526 return _wxdate2pydate(self
.GetUpperDateLimit())
528 _calendar
.CalendarCtrl_swigregister(CalendarCtrl
)
529 cvar
= _calendar
.cvar
530 CalendarNameStr
= cvar
.CalendarNameStr
532 def PreCalendarCtrl(*args
, **kwargs
):
534 PreCalendarCtrl() -> CalendarCtrl
536 Precreate a CalendarCtrl for 2-phase creation.
538 val
= _calendar
.new_PreCalendarCtrl(*args
, **kwargs
)
541 def CalendarCtrl_GetClassDefaultAttributes(*args
, **kwargs
):
543 CalendarCtrl_GetClassDefaultAttributes(int variant=WINDOW_VARIANT_NORMAL) -> VisualAttributes
545 Get the default attributes for this class. This is useful if you want
546 to use the same font or colour in your own control as in a standard
547 control -- which is a much better idea than hard coding specific
548 colours or fonts which might look completely out of place on the
549 user's system, especially if it uses themes.
551 The variant parameter is only relevant under Mac currently and is
552 ignore under other platforms. Under Mac, it will change the size of
553 the returned font. See `wx.Window.SetWindowVariant` for more about
556 return _calendar
.CalendarCtrl_GetClassDefaultAttributes(*args
, **kwargs
)
558 def _pydate2wxdate(date
):
560 assert isinstance(date
, (datetime
.datetime
, datetime
.date
))
561 tt
= date
.timetuple()
562 dmy
= (tt
[2], tt
[1]-1, tt
[0])
563 return wx
.DateTimeFromDMY(*dmy
)
565 def _wxdate2pydate(date
):
567 assert isinstance(date
, wx
.DateTime
)
569 ymd
= map(int, date
.FormatISODate().split('-'))
570 return datetime
.date(*ymd
)