X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/1e4a197e4c60e461b8068b0619692ea083e30b8b..685d898512944add00640b6e37da89159ee4d9b5:/wxPython/demo/wxPopupControl.py?ds=sidebyside diff --git a/wxPython/demo/wxPopupControl.py b/wxPython/demo/wxPopupControl.py index b3b7ad2b7d..d312a9319c 100644 --- a/wxPython/demo/wxPopupControl.py +++ b/wxPython/demo/wxPopupControl.py @@ -1,13 +1,26 @@ -from wxPython.wx import * -from wxPython.lib.popupctl import wxPopupControl -from wxPython.calendar import * - -class TestDateControl(wxPopupControl): +# 11/20/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for wx namespace +# +# 11/30/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Is it just me or are the graphics for the control not lining up right? +# +# 12/20/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o wxPopupControl -> PopupControl +# + +import wx +import wx.lib.popupctl as pop +import wx.calendar as cal + +class TestDateControl(pop.PopupControl): def __init__(self,*_args,**_kwargs): - apply(wxPopupControl.__init__,(self,) + _args,_kwargs) + apply(pop.PopupControl.__init__,(self,) + _args,_kwargs) - self.win = wxWindow(self,-1,pos = (0,0),style = 0) - self.cal = wxCalendarCtrl(self.win,-1,pos = (0,0)) + self.win = wx.Window(self,-1,pos = (0,0),style = 0) + self.cal = cal.CalendarCtrl(self.win,-1,pos = (0,0)) bz = self.cal.GetBestSize() self.win.SetSize(bz) @@ -17,7 +30,7 @@ class TestDateControl(wxPopupControl): self.SetPopupContent(self.win) # Event registration for date selection - EVT_CALENDAR_DAY(self.cal,self.cal.GetId(),self.OnCalSelected) + self.cal.Bind(cal.EVT_CALENDAR_DAY, self.OnCalSelected) # Method called when a day is selected in the calendar def OnCalSelected(self,evt): @@ -30,7 +43,7 @@ class TestDateControl(wxPopupControl): date.GetYear())) evt.Skip() - # Method overridden from wxPopupControl + # Method overridden from PopupControl # This method is called just before the popup is displayed # Use this method to format any controls in the popup def FormatContent(self): @@ -39,26 +52,29 @@ class TestDateControl(wxPopupControl): txtValue = self.GetValue() dmy = txtValue.split('/') didSet = False + if len(dmy) == 3: date = self.cal.GetDate() d = int(dmy[0]) m = int(dmy[1]) - 1 y = int(dmy[2]) + if d > 0 and d < 31: if m >= 0 and m < 12: if y > 1000: - self.cal.SetDate(wxDateTimeFromDMY(d,m,y)) + self.cal.SetDate(wx.DateTimeFromDMY(d,m,y)) didSet = True + if not didSet: - self.cal.SetDate(wxDateTime_Today()) + self.cal.SetDate(wx.DateTime_Today()) #--------------------------------------------------------------------------- -class TestPanel(wxPanel): +class TestPanel(wx.Panel): def __init__(self, parent, log): self.log = log - wxPanel.__init__(self, parent, -1) + wx.Panel.__init__(self, parent, -1) date = TestDateControl(self, -1, pos = (30,30), size = (100,22)) #---------------------------------------------------------------------- @@ -69,12 +85,10 @@ def runTest(frame, nb, log): #---------------------------------------------------------------------- - - overview = """
-