X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/41e2b43ea4fd82f188cf6f62b71c67bca8844ae9..702723413ed52b1f538d9c8deab8abfa3f8beb9a:/wxPython/src/gtk/calendar.py?ds=sidebyside diff --git a/wxPython/src/gtk/calendar.py b/wxPython/src/gtk/calendar.py index 041c2a46c3..64a43d13f8 100644 --- a/wxPython/src/gtk/calendar.py +++ b/wxPython/src/gtk/calendar.py @@ -1,6 +1,10 @@ # This file was created automatically by SWIG. # Don't modify this file, modify the SWIG interface instead. +""" +Classes for an interactive Calendar control. +""" + import _calendar import _misc @@ -143,6 +147,14 @@ class CalendarEvent(_core.CommandEvent): """GetWeekDay(self) -> int""" return _calendar.CalendarEvent_GetWeekDay(*args, **kwargs) + def PySetDate(self, date): + """takes datetime.datetime or datetime.date object""" + self.SetDate(_py2wx(date)) + + def PyGetDate(self): + """returns datetime.date object""" + return _wx2py(self.GetDate()) + class CalendarEventPtr(CalendarEvent): def __init__(self, this): @@ -451,16 +463,46 @@ class CalendarCtrl(_core.Control): Get the default attributes for this class. This is useful if you want to use the same font or colour in your own control as in a standard control -- which is a much better idea than hard coding specific - colours or fonts which might look completely out of place on the users - system, especially if it uses themes. + colours or fonts which might look completely out of place on the + user's system, especially if it uses themes. The variant parameter is only relevant under Mac currently and is ignore under other platforms. Under Mac, it will change the size of - the returned font. See SetWindowVariant for more about this. + the returned font. See `wx.Window.SetWindowVariant` for more about + this. """ return _calendar.CalendarCtrl_GetClassDefaultAttributes(*args, **kwargs) GetClassDefaultAttributes = staticmethod(GetClassDefaultAttributes) + def PySetDate(self, date): + """takes datetime.datetime or datetime.date object""" + self.SetDate(_py2wx(date)) + + def PyGetDate(self): + """returns datetime.date object""" + return _wx2py(self.GetDate()) + + def PySetLowerDateLimit(self, date): + """takes datetime.datetime or datetime.date object""" + self.SetLowerDateLimit(_py2wx(date)) + + def PySetUpperDateLimit(self, date): + """takes datetime.datetime or datetime.date object""" + self.SetUpperDateLimit(_py2wx(date)) + + def PySetDateRange(self, lowerdate, upperdate): + """takes datetime.datetime or datetime.date objects""" + self.PySetLowerDateLimit(lowerdate) + self.PySetUpperDateLimit(upperdate) + + def PyGetLowerDateLimit(self): + """returns datetime.date object""" + return _wx2py(self.GetLowerDateLimit()) + + def PyGetUpperDateLimit(self): + """returns datetime.date object""" + return _wx2py(self.GetUpperDateLimit()) + class CalendarCtrlPtr(CalendarCtrl): def __init__(self, this): @@ -488,13 +530,27 @@ def CalendarCtrl_GetClassDefaultAttributes(*args, **kwargs): Get the default attributes for this class. This is useful if you want to use the same font or colour in your own control as in a standard control -- which is a much better idea than hard coding specific - colours or fonts which might look completely out of place on the users - system, especially if it uses themes. + colours or fonts which might look completely out of place on the + user's system, especially if it uses themes. The variant parameter is only relevant under Mac currently and is ignore under other platforms. Under Mac, it will change the size of - the returned font. See SetWindowVariant for more about this. + the returned font. See `wx.Window.SetWindowVariant` for more about + this. """ return _calendar.CalendarCtrl_GetClassDefaultAttributes(*args, **kwargs) +def _py2wx(date): + import datetime + assert isinstance(date, (datetime.datetime, datetime.date)) + tt = date.timetuple() + dmy = (tt[2], tt[1]-1, tt[0]) + return wx.DateTimeFromDMY(*dmy) + +def _wx2py(date): + import datetime + assert isinstance(date, wx.DateTime) + ymd = map(int, date.FormatISODate().split('-')) + return datetime.date(*ymd) +