X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/299647acac7960652aadb008775429c1f8ea9b8d..628eae0bcd7916c57847b7eab739d4cc32534ccf:/wxPython/demo/TimeCtrl.py diff --git a/wxPython/demo/TimeCtrl.py b/wxPython/demo/TimeCtrl.py index aa5cf52762..2c8c2c98d3 100644 --- a/wxPython/demo/TimeCtrl.py +++ b/wxPython/demo/TimeCtrl.py @@ -1,25 +1,12 @@ -# 11/21/2003 - Jeff Grimmett (grimmtooth@softhome.net) # -# o Updated for wx namespace -# # 11/21/2003 - Jeff Grimmett (grimmtooth@softhome.net) # -# o wx renamer needed for timectrl lib # o presense of spin control causing probs (see spin ctrl demo for details) -# -# 12/13/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o New binders applied. Issues still exist. -# -# 12/20/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o wxTimeCtrl -> TimeCtrl -# o wxScrolledPanel -> ScrolledPanel # -import wx -import wx.lib.timectrl as timectl -import wx.lib.scrolledpanel as scrolled +import wx +import wx.lib.scrolledpanel as scrolled +import wx.lib.masked as masked #---------------------------------------------------------------------- @@ -29,23 +16,26 @@ class TestPanel( scrolled.ScrolledPanel ): scrolled.ScrolledPanel.__init__( self, parent, -1 ) self.log = log - + box_label = wx.StaticBox( self, -1, "Change Controls through API" ) + buttonbox = wx.StaticBoxSizer( box_label, wx.HORIZONTAL ) + text1 = wx.StaticText( self, -1, "12-hour format:") - self.time12 = timectl.TimeCtrl( self, -1, name="12 hour control" ) - spin1 = wx.SpinButton( self, -1, wx.DefaultPosition, (-1,20), 0 ) + self.time12 = masked.TimeCtrl( self, -1, name="12 hour control" ) + h = self.time12.GetSize().height + spin1 = wx.SpinButton( self, -1, wx.DefaultPosition, (-1,h), wx.SP_VERTICAL ) self.time12.BindSpinButton( spin1 ) text2 = wx.StaticText( self, -1, "24-hour format:") - spin2 = wx.SpinButton( self, -1, wx.DefaultPosition, (-1,20), 0 ) - self.time24 = timectl.TimeCtrl( - self, -1, name="24 hour control", fmt24hr=True, - spinButton = spin2 + spin2 = wx.SpinButton( self, -1, wx.DefaultPosition, (-1,h), wx.SP_VERTICAL ) + self.time24 = masked.TimeCtrl( + self, -1, name="24 hour control", fmt24hr=True, + spinButton = spin2 ) text3 = wx.StaticText( self, -1, "No seconds\nor spin button:") - self.spinless_ctrl = timectl.TimeCtrl( - self, -1, name="spinless control", - display_seconds = False + self.spinless_ctrl = masked.TimeCtrl( + self, -1, name="spinless control", + display_seconds = False ) grid = wx.FlexGridSizer( 0, 2, 10, 5 ) @@ -67,8 +57,8 @@ class TestPanel( scrolled.ScrolledPanel ): buttonChange = wx.Button( self, -1, "Change Controls") self.radio12to24 = wx.RadioButton( - self, -1, "Copy 12-hour time to 24-hour control", - wx.DefaultPosition, wx.DefaultSize, wx.RB_GROUP + self, -1, "Copy 12-hour time to 24-hour control", + wx.DefaultPosition, wx.DefaultSize, wx.RB_GROUP ) self.radio24to12 = wx.RadioButton( @@ -83,9 +73,7 @@ class TestPanel( scrolled.ScrolledPanel ): radio_vbox.Add( self.radio24to12, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) radio_vbox.Add( self.radioWx, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) radio_vbox.Add( self.radioMx, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) - - box_label = wx.StaticBox( self, -1, "Change Controls through API" ) - buttonbox = wx.StaticBoxSizer( box_label, wx.HORIZONTAL ) + buttonbox.Add( buttonChange, 0, wx.ALIGN_CENTRE|wx.ALL, 5 ) buttonbox.Add( radio_vbox, 0, wx.ALIGN_CENTRE|wx.ALL, 5 ) @@ -99,17 +87,17 @@ class TestPanel( scrolled.ScrolledPanel ): self.set_bounds = wx.CheckBox( self, -1, "Set time bounds:" ) minlabel = wx.StaticText( self, -1, "minimum time:" ) - self.min = timectl.TimeCtrl( self, -1, name="min", display_seconds = False ) + self.min = masked.TimeCtrl( self, -1, name="min", display_seconds = False ) self.min.Enable( False ) maxlabel = wx.StaticText( self, -1, "maximum time:" ) - self.max = timectl.TimeCtrl( self, -1, name="max", display_seconds = False ) + self.max = masked.TimeCtrl( self, -1, name="max", display_seconds = False ) self.max.Enable( False ) self.limit_check = wx.CheckBox( self, -1, "Limit control" ) label = wx.StaticText( self, -1, "Resulting time control:" ) - self.target_ctrl = timectl.TimeCtrl( self, -1, name="new" ) + self.target_ctrl = masked.TimeCtrl( self, -1, name="new" ) grid2 = wx.FlexGridSizer( 0, 2, 0, 0 ) grid2.Add( (20, 0), 0, wx.ALIGN_LEFT|wx.ALL, 5 ) @@ -155,14 +143,14 @@ class TestPanel( scrolled.ScrolledPanel ): self.SetupScrolling() self.Bind(wx.EVT_BUTTON, self.OnButtonClick, buttonChange ) - self.Bind(timectl.EVT_TIMEUPDATE, self.OnTimeChange, self.time12 ) - self.Bind(timectl.EVT_TIMEUPDATE, self.OnTimeChange, self.time24 ) - self.Bind(timectl.EVT_TIMEUPDATE, self.OnTimeChange, self.spinless_ctrl ) + self.Bind(masked.EVT_TIMEUPDATE, self.OnTimeChange, self.time12 ) + self.Bind(masked.EVT_TIMEUPDATE, self.OnTimeChange, self.time24 ) + self.Bind(masked.EVT_TIMEUPDATE, self.OnTimeChange, self.spinless_ctrl ) self.Bind(wx.EVT_CHECKBOX, self.OnBoundsCheck, self.set_bounds ) self.Bind(wx.EVT_CHECKBOX, self.SetTargetMinMax, self.limit_check ) - self.Bind(timectl.EVT_TIMEUPDATE, self.SetTargetMinMax, self.min ) - self.Bind(timectl.EVT_TIMEUPDATE, self.SetTargetMinMax, self.max ) - self.Bind(timectl.EVT_TIMEUPDATE, self.OnTimeChange, self.target_ctrl ) + self.Bind(masked.EVT_TIMEUPDATE, self.SetTargetMinMax, self.min ) + self.Bind(masked.EVT_TIMEUPDATE, self.SetTargetMinMax, self.max ) + self.Bind(masked.EVT_TIMEUPDATE, self.OnTimeChange, self.target_ctrl ) def OnTimeChange( self, event ): @@ -182,10 +170,10 @@ class TestPanel( scrolled.ScrolledPanel ): elif self.radioWx.GetValue(): now = wx.DateTime_Now() self.time12.SetValue( now ) - # (demonstrates that G/SetValue returns/takes a wxDateTime) + # (demonstrates that G/SetValue returns/takes a wx.DateTime) self.time24.SetValue( self.time12.GetValue(as_wxDateTime=True) ) - # (demonstrates that G/SetValue returns/takes a wxTimeSpan) + # (demonstrates that G/SetValue returns/takes a wx.TimeSpan) self.spinless_ctrl.SetValue( self.time12.GetValue(as_wxTimeSpan=True) ) elif self.radioMx.GetValue(): @@ -217,9 +205,7 @@ class TestPanel( scrolled.ScrolledPanel ): min, max = None, None cur_min, cur_max = self.target_ctrl.GetBounds() - - # jmg - A little expirimental change to ensure that min - # or max contain valid values before we use them + print cur_min, min if min and (min != cur_min): self.target_ctrl.SetMin( min ) if max and (max != cur_max): self.target_ctrl.SetMax( max ) @@ -240,8 +226,11 @@ def runTest( frame, nb, log ): return win #---------------------------------------------------------------------- - -overview = timectl.__doc__ +import wx.lib.masked.timectrl as timectl +overview = """ +

+""" + timectl.__doc__ + """
+
""" if __name__ == '__main__': import sys,os