]> git.saurik.com Git - wxWidgets.git/blobdiff - wxPython/demo/MaskedNumCtrl.py
apparently the check for too small rect is needed not only with wxNB_MULTILINE (see...
[wxWidgets.git] / wxPython / demo / MaskedNumCtrl.py
index e0e4077600da4d75c42b252dea3e91089739f22f..277f3e2e80223fa8232f496e40524fe67f7695f6 100644 (file)
@@ -4,8 +4,8 @@ import  sys
 import  traceback
 
 import  wx
 import  traceback
 
 import  wx
-import  wx.lib.maskededit       as me
-import  wx.lib.maskednumctrl    as mnum
+from    wx.lib import masked
+
 #----------------------------------------------------------------------
 
 class TestPanel( wx.Panel ):
 #----------------------------------------------------------------------
 
 class TestPanel( wx.Panel ):
@@ -16,40 +16,40 @@ class TestPanel( wx.Panel ):
         panel = wx.Panel( self, -1 )
 
         header = wx.StaticText(panel, -1, """\
         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:" )
 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:" )
                                 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:" )
                                 )
 
         groupcharlabel = wx.StaticText( panel,-1, "Grouping char:" )
-        self.groupchar = me.MaskedTextCtrl( 
+        self.groupchar = masked.TextCtrl(
                                 panel, -1, value=',', mask='&', excludeChars = '-()',
                                 formatcodes='F', emptyInvalid=True, validRequired=True
                                 )
 
         decimalcharlabel = wx.StaticText( panel,-1, "Decimal char:" )
                                 panel, -1, value=',', mask='&', excludeChars = '-()',
                                 formatcodes='F', emptyInvalid=True, validRequired=True
                                 )
 
         decimalcharlabel = wx.StaticText( panel,-1, "Decimal char:" )
-        self.decimalchar = me.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:" )
                                 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.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 )
 
 
         self.max.Enable( False )
 
 
@@ -68,7 +68,7 @@ The controls at the top reconfigure the resulting control at the bottom.
         font.SetWeight(wx.BOLD)
         label.SetFont(font)
 
         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
 
         label_numselect = wx.StaticText( panel, -1, """\
 Programmatically set the above
@@ -79,16 +79,16 @@ value entry ctrl:""")
 
         grid1 = wx.FlexGridSizer( 0, 4, 0, 0 )
         grid1.Add( intlabel, 0, wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
 
         grid1 = wx.FlexGridSizer( 0, 4, 0, 0 )
         grid1.Add( intlabel, 0, wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
-        grid1.Add( self.integerwidth, 0, wx.FIXED_MINSIZE|wx.ALIGN_LEFT|wx.ALL, 5 )
+        grid1.Add( self.integerwidth, 0, wx.ALIGN_LEFT|wx.ALL, 5 )
 
         grid1.Add( groupcharlabel, 0, wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
 
         grid1.Add( groupcharlabel, 0, wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
-        grid1.Add( self.groupchar, 0, wx.FIXED_MINSIZE|wx.ALIGN_LEFT|wx.ALL, 5 )
+        grid1.Add( self.groupchar, 0, wx.ALIGN_LEFT|wx.ALL, 5 )
 
         grid1.Add( fraclabel, 0, wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
 
         grid1.Add( fraclabel, 0, wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
-        grid1.Add( self.fractionwidth, 0, wx.FIXED_MINSIZE|wx.ALIGN_LEFT|wx.ALL, 5 )
+        grid1.Add( self.fractionwidth, 0, wx.ALIGN_LEFT|wx.ALL, 5 )
 
         grid1.Add( decimalcharlabel, 0, wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
 
         grid1.Add( decimalcharlabel, 0, wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
-        grid1.Add( self.decimalchar, 0, wx.FIXED_MINSIZE|wx.ALIGN_LEFT|wx.ALL, 5 )
+        grid1.Add( self.decimalchar, 0, wx.ALIGN_LEFT|wx.ALL, 5 )
 
         grid1.Add( self.set_min, 0, wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
         grid1.Add( self.min, 0, wx.ALIGN_LEFT|wx.ALL, 5 )
 
         grid1.Add( self.set_min, 0, wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
         grid1.Add( self.min, 0, wx.ALIGN_LEFT|wx.ALL, 5 )
@@ -141,15 +141,15 @@ value entry ctrl:""")
         panel.Move( (50,10) )
         self.panel = panel
 
         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(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 )
 
         self.Bind(wx.EVT_CHECKBOX, self.SetTargetMinMax, self.limit_target )
         self.Bind(wx.EVT_CHECKBOX, self.OnSetAllowNone, self.allow_none )
@@ -158,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(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 )
 
 
         self.Bind(wx.EVT_COMBOBOX, self.OnNumberSelect, self.numselect )
 
 
@@ -323,7 +323,11 @@ def runTest( frame, nb, log ):
     return win
 
 #----------------------------------------------------------------------
     return win
 
 #----------------------------------------------------------------------
-overview = mnum.__doc__
+import wx.lib.masked.numctrl as mnum
+overview = """<html>
+<PRE><FONT SIZE=-1>
+""" + mnum.__doc__ + """
+</FONT></PRE>"""
 
 if __name__ == '__main__':
     import sys,os
 
 if __name__ == '__main__':
     import sys,os