Permalink
Browse files

Merge pull request #681 from RobinD42/fix-issue670

Add converting to datetime to PyGetDate methods
  • Loading branch information...
RobinD42 committed Jan 12, 2018
2 parents b6fb245 + 40e8eb0 commit 5f1ee010146a5254548af011b801f3da741bc6e3
Showing with 33 additions and 2 deletions.
  1. +7 −1 etg/calctrl.py
  2. +5 −1 etg/dateevt.py
  3. +21 −0 unittests/test_calctrl.py
View
@@ -70,8 +70,14 @@ def run():
c.find('HitTest.wd').out = True
c.find('SetAttr.attr').transfer = True
c.addPyMethod('PyGetDate', '(self)',
doc="Return the date as a Python datetime.date object.",
body="return wx.wxdate2pydate(self.GetDate())",
deprecated="Use GetDate instead.")
# We have convertFromPyObject mapping in place for parameters, so we
# don't need a full wrapper method for these.
c.addPyCode("""\
{name}.PyGetDate = wx.deprecated({name}.GetDate, 'Use GetDate instead.')
{name}.PySetDate = wx.deprecated({name}.SetDate, 'Use SetDate instead.')
{name}.PySetDateRange = wx.deprecated({name}.SetDateRange, 'Use SetDateRange instead.')
""".format(name=c.name[2:]))
View
@@ -42,8 +42,12 @@ def run():
EVT_TIME_CHANGED = wx.PyEventBinder( wxEVT_TIME_CHANGED, 1 )
""")
c.addPyMethod('PyGetDate', '(self)',
doc="Return the date as a Python datetime.date object.",
body="return wx.wxdate2pydate(self.GetDate())",
deprecated="Use GetDate instead.")
c.addPyCode("""\
DateEvent.PyGetDate = wx.deprecated(DateEvent.GetDate, 'Use GetDate instead.')
DateEvent.PySetDate = wx.deprecated(DateEvent.SetDate, 'Use SetDate instead.')
""")
View
@@ -2,6 +2,7 @@
from unittests import wtc
import wx
import wx.adv
import datetime
#---------------------------------------------------------------------------
@@ -42,6 +43,13 @@ def test_calctrl3(self):
cal.Create(self.frame, date=wx.DateTime.Today())
def test_calctrl4(self):
cal = wx.adv.CalendarCtrl(self.frame, date=wx.DateTime.Today())
d = cal.PyGetDate()
assert isinstance(d, datetime.datetime)
def test_genericcalctrl2(self):
cal = wx.adv.GenericCalendarCtrl(self.frame, date=wx.DateTime.Today())
@@ -51,6 +59,19 @@ def test_genericcalctrl3(self):
cal.Create(self.frame, date=wx.DateTime.Today())
def test_genericcalctrl4(self):
cal = wx.adv.GenericCalendarCtrl(self.frame, date=wx.DateTime.Today())
d = cal.PyGetDate()
assert isinstance(d, datetime.datetime)
def test_calevt(self):
evt = wx.adv.CalendarEvent()
evt.SetDate(wx.DateTime.Today())
d = evt.PyGetDate()
assert isinstance(d, datetime.datetime)
#---------------------------------------------------------------------------

0 comments on commit 5f1ee01

Please sign in to comment.