X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/299647acac7960652aadb008775429c1f8ea9b8d..b4eecebd423df0c6efe86d7658cd3df818d67ed8:/wxPython/demo/MaskedNumCtrl.py?ds=sidebyside diff --git a/wxPython/demo/MaskedNumCtrl.py b/wxPython/demo/MaskedNumCtrl.py index 855726b100..28a488584b 100644 --- a/wxPython/demo/MaskedNumCtrl.py +++ b/wxPython/demo/MaskedNumCtrl.py @@ -1,26 +1,11 @@ -# 11/20/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Updated for wx namespace -# -# 11/29/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o wx.lib.maskednumctrl needs hit up with the renamer and new binders -# -# 12/09/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o Issues with lib corrected. -# -# 12/20/2003 - Jeff Grimmett (grimmtooth@softhome.net) -# -# o wxMaskedNumCtrl -> MaskedNumCtrl -# import string import sys import traceback import wx -import wx.lib.maskednumctrl as mnum +from wx.lib import masked + #---------------------------------------------------------------------- class TestPanel( wx.Panel ): @@ -31,40 +16,40 @@ class TestPanel( wx.Panel ): panel = wx.Panel( self, -1 ) header = wx.StaticText(panel, -1, """\ -This shows the various options for MaskedNumCtrl. +This shows the various options for masked.NumCtrl. The controls at the top reconfigure the resulting control at the bottom. """) header.SetForegroundColour( "Blue" ) intlabel = wx.StaticText( panel, -1, "Integer width:" ) - self.integerwidth = mnum.MaskedNumCtrl( + self.integerwidth = masked.NumCtrl( panel, value=10, integerWidth=2, allowNegative=False ) fraclabel = wx.StaticText( panel, -1, "Fraction width:" ) - self.fractionwidth = mnum.MaskedNumCtrl( - panel, value=0, integerWidth=2, allowNegative=False + self.fractionwidth = masked.NumCtrl( + panel, value=0, integerWidth=2, allowNegative=False ) groupcharlabel = wx.StaticText( panel,-1, "Grouping char:" ) - self.groupchar = mnum.MaskedTextCtrl( - panel, -1, value=',', mask='&', excludeChars = '-()', - formatcodes='F', emptyInvalid=True, validRequired=True + self.groupchar = masked.TextCtrl( + panel, -1, value=',', mask='*', includeChars = ' ', excludeChars = '-()0123456789', + formatcodes='F', emptyInvalid=False, validRequired=True ) decimalcharlabel = wx.StaticText( panel,-1, "Decimal char:" ) - self.decimalchar = mnum.MaskedTextCtrl( + self.decimalchar = masked.TextCtrl( panel, -1, value='.', mask='&', excludeChars = '-()', formatcodes='F', emptyInvalid=True, validRequired=True ) self.set_min = wx.CheckBox( panel, -1, "Set minimum value:" ) - # Create this MaskedNumCtrl using factory, to show how: - self.min = mnum.MaskedNumCtrl( panel, integerWidth=5, fractionWidth=2 ) + # Create this masked.NumCtrl using factory, to show how: + self.min = masked.Ctrl( panel, integerWidth=5, fractionWidth=2, controlType=masked.controlTypes.NUMBER ) self.min.Enable( False ) self.set_max = wx.CheckBox( panel, -1, "Set maximum value:" ) - self.max = mnum.MaskedNumCtrl( panel, integerWidth=5, fractionWidth=2 ) + self.max = masked.NumCtrl( panel, integerWidth=5, fractionWidth=2 ) self.max.Enable( False ) @@ -83,7 +68,7 @@ The controls at the top reconfigure the resulting control at the bottom. font.SetWeight(wx.BOLD) label.SetFont(font) - self.target_ctl = mnum.MaskedNumCtrl( panel, -1, name="target control" ) + self.target_ctl = masked.NumCtrl( panel, -1, name="target control" ) label_numselect = wx.StaticText( panel, -1, """\ Programmatically set the above @@ -156,15 +141,15 @@ value entry ctrl:""") panel.Move( (50,10) ) self.panel = panel - self.Bind(mnum.EVT_MASKEDNUM, self.OnSetIntWidth, self.integerwidth ) - self.Bind(mnum.EVT_MASKEDNUM, self.OnSetFractionWidth, self.fractionwidth ) + self.Bind(masked.EVT_NUM, self.OnSetIntWidth, self.integerwidth ) + self.Bind(masked.EVT_NUM, self.OnSetFractionWidth, self.fractionwidth ) self.Bind(wx.EVT_TEXT, self.OnSetGroupChar, self.groupchar ) self.Bind(wx.EVT_TEXT, self.OnSetDecimalChar, self.decimalchar ) self.Bind(wx.EVT_CHECKBOX, self.OnSetMin, self.set_min ) self.Bind(wx.EVT_CHECKBOX, self.OnSetMax, self.set_max ) - self.Bind(mnum.EVT_MASKEDNUM, self.SetTargetMinMax, self.min ) - self.Bind(mnum.EVT_MASKEDNUM, self.SetTargetMinMax, self.max ) + self.Bind(masked.EVT_NUM, self.SetTargetMinMax, self.min ) + self.Bind(masked.EVT_NUM, self.SetTargetMinMax, self.max ) self.Bind(wx.EVT_CHECKBOX, self.SetTargetMinMax, self.limit_target ) self.Bind(wx.EVT_CHECKBOX, self.OnSetAllowNone, self.allow_none ) @@ -173,7 +158,7 @@ value entry ctrl:""") self.Bind(wx.EVT_CHECKBOX, self.OnSetUseParens, self.use_parens ) self.Bind(wx.EVT_CHECKBOX, self.OnSetSelectOnEntry, self.select_on_entry ) - self.Bind(mnum.EVT_MASKEDNUM, self.OnTargetChange, self.target_ctl ) + self.Bind(masked.EVT_NUM, self.OnTargetChange, self.target_ctl ) self.Bind(wx.EVT_COMBOBOX, self.OnNumberSelect, self.numselect ) @@ -338,9 +323,13 @@ def runTest( frame, nb, log ): return win #---------------------------------------------------------------------- -overview = mnum.__doc__ +import wx.lib.masked.numctrl as mnum +overview = """ +
+""" + mnum.__doc__ + """ +""" if __name__ == '__main__': import sys,os import run - run.main(['', os.path.basename(sys.argv[0])]) + run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])