X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/dfbb58858530d18c34c532019d64d45122dfc798..702723413ed52b1f538d9c8deab8abfa3f8beb9a:/wxPython/src/gtk/calendar.py?ds=sidebyside diff --git a/wxPython/src/gtk/calendar.py b/wxPython/src/gtk/calendar.py index 180dda2bdd..64a43d13f8 100644 --- a/wxPython/src/gtk/calendar.py +++ b/wxPython/src/gtk/calendar.py @@ -147,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): @@ -449,10 +457,52 @@ class CalendarCtrl(_core.Control): return _calendar.CalendarCtrl_GetYearControl(*args, **kwargs) def GetClassDefaultAttributes(*args, **kwargs): - """GetClassDefaultAttributes(int variant=WINDOW_VARIANT_NORMAL) -> VisualAttributes""" + """ + GetClassDefaultAttributes(int variant=WINDOW_VARIANT_NORMAL) -> VisualAttributes + + 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 + 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 `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): @@ -474,7 +524,33 @@ def PreCalendarCtrl(*args, **kwargs): return val def CalendarCtrl_GetClassDefaultAttributes(*args, **kwargs): - """CalendarCtrl_GetClassDefaultAttributes(int variant=WINDOW_VARIANT_NORMAL) -> VisualAttributes""" + """ + CalendarCtrl_GetClassDefaultAttributes(int variant=WINDOW_VARIANT_NORMAL) -> VisualAttributes + + 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 + 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 `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) +