#
# o A few changes to correct my own mistakes earlier :-).
#
+# 12/20/2003 - Jeff Grimmett (grimmtooth@softhome.net)
+#
+# o wxMaskedTextCtrl -> MaskedTextCtrl
+# o wxMaskedComboBox -> MaskedComboBox
+# o wxIpAddrCtrl -> IpAddrCtrl
+# o wxMaskedNumCtrl -> MaskedNumCtrl
+# o wxTimeCtrl -> TimeCtrl
+# o wxScrolledPanel -> ScrolledPanel
+#
import string
import sys
mask = wx.StaticText( self, -1, "Mask Value" )
formatcode = wx.StaticText( self, -1, "Format" )
regex = wx.StaticText( self, -1, "Regexp Validator(opt.)" )
- ctrl = wx.StaticText( self, -1, "wxMaskedTextCtrl" )
+ ctrl = wx.StaticText( self, -1, "MaskedTextCtrl" )
description.SetFont( wx.Font(9, wx.SWISS, wx.NORMAL, wx.BOLD))
mask.SetFont( wx.Font(9, wx.SWISS, wx.NORMAL, wx.BOLD))
sizer.Add( wx.StaticText( self, -1, control[4]) )
if control in controls:
- newControl = med.wxMaskedTextCtrl( self, -1, "",
+ newControl = med.MaskedTextCtrl( self, -1, "",
mask = control[1],
excludeChars = control[2],
formatcodes = control[3],
#----------------------------------------------------------------------------
-class demoPage1(scroll.wxScrolledPanel, demoMixin):
+class demoPage1(scroll.ScrolledPanel, demoMixin):
def __init__(self, parent, log):
- scroll.wxScrolledPanel.__init__(self, parent, -1)
+ scroll.ScrolledPanel.__init__(self, parent, -1)
self.sizer = wx.BoxSizer( wx.VERTICAL )
self.editList = []
self.changeControlParams( event, "fillChar", '?', ' ' )
-class demoPage2(scroll.wxScrolledPanel, demoMixin):
+class demoPage2(scroll.ScrolledPanel, demoMixin):
def __init__( self, parent, log ):
self.log = log
- scroll.wxScrolledPanel.__init__( self, parent, -1 )
+ scroll.ScrolledPanel.__init__( self, parent, -1 )
self.sizer = wx.BoxSizer( wx.VERTICAL )
label = wx.StaticText( self, -1, """\
self.SetupScrolling()
-class demoPage3(scroll.wxScrolledPanel, demoMixin):
+class demoPage3(scroll.ScrolledPanel, demoMixin):
def __init__(self, parent, log):
self.log = log
- scroll.wxScrolledPanel.__init__(self, parent, -1)
+ scroll.ScrolledPanel.__init__(self, parent, -1)
self.sizer = wx.BoxSizer( wx.VERTICAL )
self.editList = []
label = wx.StaticText( self, -1, """\
-Here wxMaskedTextCtrls that have default values. The states
+Here MaskedTextCtrls that have default values. The states
control has a list of valid values, and the unsigned integer
has a legal range specified.
""")
self.changeControlParams( event, "validRequired", True, False )
-class demoPage4(scroll.wxScrolledPanel, demoMixin):
+class demoPage4(scroll.ScrolledPanel, demoMixin):
def __init__( self, parent, log ):
self.log = log
- scroll.wxScrolledPanel.__init__( self, parent, -1 )
+ scroll.ScrolledPanel.__init__( self, parent, -1 )
self.sizer = wx.BoxSizer( wx.VERTICAL )
label = wx.StaticText( self, -1, """\
description = wx.StaticText( self, -1, "Description" )
autofmt = wx.StaticText( self, -1, "AutoFormat Code" )
fields = wx.StaticText( self, -1, "Field Objects" )
- ctrl = wx.StaticText( self, -1, "wxMaskedTextCtrl" )
+ ctrl = wx.StaticText( self, -1, "MaskedTextCtrl" )
description.SetFont( wx.Font( 9, wx.SWISS, wx.NORMAL, wx.BOLD ) )
autofmt.SetFont( wx.Font( 9, wx.SWISS, wx.NORMAL, wx.BOLD ) )
grid.Add( wx.StaticText( self, -1, "Restricted Area Code"), 0, wx.ALIGN_LEFT )
grid.Add( wx.StaticText( self, -1, autoformat), 0, wx.ALIGN_LEFT )
grid.Add( wx.StaticText( self, -1, fieldsLabel), 0, wx.ALIGN_LEFT )
- grid.Add( med.wxMaskedTextCtrl( self, -1, "",
+ grid.Add( med.MaskedTextCtrl( self, -1, "",
autoformat = autoformat,
fields = fieldsDict,
demo = True,
{1: Field(choices=[
"03", "04", "05"],
choiceRequired=True)}"""
- exp = med.wxMaskedTextCtrl( self, -1, "",
+ exp = med.MaskedTextCtrl( self, -1, "",
autoformat = autoformat,
fields = fieldsDict,
demo = True,
1: Field(choices=["1234", "5678"],
choiceRequired=False)}"""
autoformat = "USZIPPLUS4"
- zip = med.wxMaskedTextCtrl( self, -1, "",
+ zip = med.MaskedTextCtrl( self, -1, "",
autoformat = autoformat,
fields = fieldsDict,
demo = True,
self.SetupScrolling()
-class demoPage5(scroll.wxScrolledPanel, demoMixin):
+class demoPage5(scroll.ScrolledPanel, demoMixin):
def __init__( self, parent, log ):
self.log = log
- scroll.wxScrolledPanel.__init__( self, parent, -1 )
+ scroll.ScrolledPanel.__init__( self, parent, -1 )
self.sizer = wx.BoxSizer( wx.VERTICAL )
labelMaskedCombos = wx.StaticText( self, -1, """\
-These are some examples of wxMaskedComboBox:""")
+These are some examples of MaskedComboBox:""")
labelMaskedCombos.SetForegroundColour( "Blue" )
A state selector; only
"legal" values can be
entered:""")
- statecode = med.wxMaskedComboBox( self, -1, med.states[0],
+ statecode = med.MaskedComboBox( self, -1, med.states[0],
choices = med.states,
autoformat="USSTATE")
text from a list of numeric codes:""")
choices = ["91", "136", "305", "4579"]
- code = med.wxMaskedComboBox( self, -1, choices[0],
+ code = med.MaskedComboBox( self, -1, choices[0],
choices = choices,
choiceRequired = True,
formatcodes = "F_r",
labelIpAddrs = wx.StaticText( self, -1, """\
-Here are some examples of wxIpAddrCtrl, a control derived from wxMaskedTextCtrl:""")
+Here are some examples of IpAddrCtrl, a control derived from MaskedTextCtrl:""")
labelIpAddrs.SetForegroundColour( "Blue" )
label_ipaddr1 = wx.StaticText( self, -1, "An empty control:")
- ipaddr1 = med.wxIpAddrCtrl( self, -1, style = wx.TE_PROCESS_TAB )
+ ipaddr1 = med.IpAddrCtrl( self, -1, style = wx.TE_PROCESS_TAB )
label_ipaddr2 = wx.StaticText( self, -1, "A restricted mask:")
- ipaddr2 = med.wxIpAddrCtrl( self, -1, mask=" 10. 1.109.###" )
+ ipaddr2 = med.IpAddrCtrl( self, -1, mask=" 10. 1.109.###" )
label_ipaddr3 = wx.StaticText( self, -1, """\
labelNumerics = wx.StaticText( self, -1, """\
-Here are some useful configurations of a wxMaskedTextCtrl for integer and floating point input that still treat
-the control as a text control. (For a true numeric control, check out the wxMaskedNumCtrl class!)""")
+Here are some useful configurations of a MaskedTextCtrl for integer and floating point input that still treat
+the control as a text control. (For a true numeric control, check out the MaskedNumCtrl class!)""")
labelNumerics.SetForegroundColour( "Blue" )
label_intctrl1 = wx.StaticText( self, -1, """\
An integer entry control with
shifting insert enabled:""")
- self.intctrl1 = med.wxMaskedTextCtrl(self, -1, name='intctrl', mask="#{9}", formatcodes = '_-,F>')
+ self.intctrl1 = med.MaskedTextCtrl(self, -1, name='intctrl', mask="#{9}", formatcodes = '_-,F>')
label_intctrl2 = wx.StaticText( self, -1, """\
Right-insert integer entry:""")
- self.intctrl2 = med.wxMaskedTextCtrl(self, -1, name='intctrl', mask="#{9}", formatcodes = '_-,Fr')
+ self.intctrl2 = med.MaskedTextCtrl(self, -1, name='intctrl', mask="#{9}", formatcodes = '_-,Fr')
label_floatctrl = wx.StaticText( self, -1, """\
A floating point entry control
with right-insert for ordinal:""")
- self.floatctrl = med.wxMaskedTextCtrl(self, -1, name='floatctrl', mask="#{9}.#{2}", formatcodes="F,_-R", useParensForNegatives=False)
+ self.floatctrl = med.MaskedTextCtrl(self, -1, name='floatctrl', mask="#{9}.#{2}", formatcodes="F,_-R", useParensForNegatives=False)
self.floatctrl.SetFieldParameters(0, formatcodes='r<', validRequired=True) # right-insert, require explicit cursor movement to change fields
self.floatctrl.SetFieldParameters(1, defaultValue='00') # don't allow blank fraction
import sys
import wx
-import wx.lib.infoframe as infoframe
+import wx.lib.infoframe
#----------------------------------------------------------------------
#----------------------------------------------------------------------
-overview = infoframe.__doc__
+overview = wx.lib.infoframe.__doc__
def runTest(frame, nb, log):
"""
This method is used by the wxPython Demo Framework for integrating
this demo with the rest.
"""
- win = MyFrame(infoframe.wxPyInformationalMessagesFrame())
+ win = MyFrame(wx.lib.infoframe.PyInformationalMessagesFrame())
frame.otherWin = win
win.Show(1)
## output.SetOtherMenuBar(menubar,menuname="Output")
## def OnClose(self,event):
-## if isinstance(sys.stdout,wxPyInformationalMessagesFrame):
+## if isinstance(sys.stdout,wx.lib.infoframe.PyInformationalMessagesFrame):
## sys.stdout.close()
## self.Destroy()
# Override the default output window and point it to the
# custom class.
- outputWindowClass = infoframe.wxPyInformationalMessagesFrame
+ outputWindowClass = wx.lib.infoframe.PyInformationalMessagesFrame
def OnInit(self):
self.SetTopWindow(frame)
# Associate the frame with stdout.
- if isinstance(sys.stdout, infoframe.wxPyInformationalMessagesFrame):
+ if isinstance(sys.stdout, wx.lib.infoframe.PyInformationalMessagesFrame):
sys.stdout.SetParent(frame)
print "Starting.\n",
#
# o editor lib hasn't been hit by the renamer yet.
#
+# 12/21/2003 - Jeff Grimmett (grimmtooth@softhome.net)
+#
+# o wxEditor -> Editor
+#
import wx
import wx.lib.editor as editor
def runTest(frame, nb, log):
win = wx.Panel(nb, -1)
- ed = editor.wxEditor(win, -1, style=wx.SUNKEN_BORDER)
+ ed = editor.Editor(win, -1, style=wx.SUNKEN_BORDER)
box = wx.BoxSizer(wx.VERTICAL)
box.Add(ed, 1, wx.ALL|wx.GROW, 1)
win.SetSizer(box)
ed.SetText(["",
"This is a simple text editor, the class name is",
- "wxEditor. Type a few lines and try it out.",
+ "Editor. Type a few lines and try it out.",
"",
"It uses Windows-style key commands that can be overridden by subclassing.",
"Mouse select works. Here are the key commands:",
overview = """
-The wxEditor class implements a simple text editor using wxPython. You
-can create a custom editor by subclassing wxEditor. Even though much of
+The Editor class implements a simple text editor using wxPython. You
+can create a custom editor by subclassing Editor. Even though much of
the editor is implemented in Python, it runs surprisingly smoothly on
normal hardware with small files.
How to use it
-------------
-The demo code (demo/wxEditor.py) shows how to use wxEditor as a simple text
+The demo code (demo/Editor.py) shows how to use Editor as a simple text
box. Use the SetText() and GetText() methods to set or get text from
the component; these both use a list of strings.
The samples/FrogEdit directory has an example of a simple text editor
-application that uses the wxEditor component.
+application that uses the Editor component.
Subclassing
-----------
#
# o All issues corrected
#
+# 12/20/2003 - Jeff Grimmett (grimmtooth@softhome.net)
+#
+# o wxIntCtrl -> IntCtrl
+#
import wx
-import wx.lib.intctrl as intctrl
+import wx.lib.intctrl
#----------------------------------------------------------------------
panel = wx.Panel( self, -1 )
self.set_min = wx.CheckBox( panel, -1, "Set minimum value:" )
- self.min = intctrl.wxIntCtrl( panel, size=( 50, -1 ) )
+ self.min = wx.lib.intctrl.IntCtrl( panel, size=( 50, -1 ) )
self.min.Enable( False )
self.set_max = wx.CheckBox( panel, -1, "Set maximum value:" )
- self.max = intctrl.wxIntCtrl( panel, size=( 50, -1 ) )
+ self.max = wx.lib.intctrl.IntCtrl( panel, size=( 50, -1 ) )
self.max.Enable( False )
self.limit_target = wx.CheckBox( panel, -1, "Limit control" )
self.allow_long = wx.CheckBox( panel, -1, "Allow long integers" )
label = wx.StaticText( panel, -1, "Resulting integer control:" )
- self.target_ctl = intctrl.wxIntCtrl( panel )
+ self.target_ctl = wx.lib.intctrl.IntCtrl( panel )
grid = wx.FlexGridSizer( 0, 2, 0, 0 )
grid.Add( self.set_min, 0, wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
self.Bind(wx.EVT_CHECKBOX, self.OnSetAllowNone, self.allow_none)
self.Bind(wx.EVT_CHECKBOX, self.OnSetAllowLong, self.allow_long)
- self.Bind(intctrl.EVT_INT, self.SetTargetMinMax, self.min)
- self.Bind(intctrl.EVT_INT, self.SetTargetMinMax, self.max)
- self.Bind(intctrl.EVT_INT, self.OnTargetChange, self.target_ctl)
+ self.Bind(wx.lib.intctrl.EVT_INT, self.SetTargetMinMax, self.min)
+ self.Bind(wx.lib.intctrl.EVT_INT, self.SetTargetMinMax, self.max)
+ self.Bind(wx.lib.intctrl.EVT_INT, self.OnTargetChange, self.target_ctl)
def OnSetMin( self, event ):
overview = """<html><body>
<P>
-<B>wxIntCtrl</B> provides a control that takes and returns integers as
+<B>IntCtrl</B> provides a control that takes and returns integers as
value, and provides bounds support and optional value limiting.
<P>
<P>
-Here's the API for wxIntCtrl:
+Here's the API for IntCtrl:
<DL><PRE>
- <B>wxIntCtrl</B>(
+ <B>IntCtrl</B>(
parent, id = -1,
<B>value</B> = 0,
<B>min</B> = None,
#
# o lib.mixins.listctrl needs wx renamer applied.
#
+# 12/21/2003 - Jeff Grimmett (grimmtooth@softhome.net)
+#
+# o wxListCtrlAutoWidthMixin -> ListCtrlAutoWidthMixin
+#
import wx
import wx.lib.mixins.listctrl as listmix
#----------------------------------------------------------------------
-class KeyLog(wx.ListCtrl, listmix.wxListCtrlAutoWidthMixin):
+class KeyLog(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin):
def __init__(self, parent):
wx.ListCtrl.__init__(self, parent, -1,
style = wx.LC_REPORT|wx.LC_VRULES|wx.LC_HRULES)
- listmix.wxListCtrlAutoWidthMixin.__init__(self)
+ listmix.ListCtrlAutoWidthMixin.__init__(self)
self.InsertColumn(0, "Event Type")
self.InsertColumn(1, "Key Name")
# o ColumnSorterMixin implementation was broke - added event.Skip()
# to column click event to allow event to fall through to mixin.
#
+# 12/21/2003 - Jeff Grimmett (grimmtooth@softhome.net)
+#
+# o wxColumnSorterMixin -> ColumnSorterMixin
+# o wxListCtrlAutoWidthMixin -> ListCtrlAutoWidthMixin
+#
import wx
import wx.lib.mixins.listctrl as listmix
#---------------------------------------------------------------------------
-class TestListCtrl(wx.ListCtrl, listmix.wxListCtrlAutoWidthMixin):
+class TestListCtrl(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin):
def __init__(self, parent, ID, pos=wx.DefaultPosition,
size=wx.DefaultSize, style=0):
wx.ListCtrl.__init__(self, parent, ID, pos, size, style)
- listmix.wxListCtrlAutoWidthMixin.__init__(self)
+ listmix.ListCtrlAutoWidthMixin.__init__(self)
-class TestListCtrlPanel(wx.Panel, listmix.wxColumnSorterMixin):
+class TestListCtrlPanel(wx.Panel, listmix.ColumnSorterMixin):
def __init__(self, parent, log):
wx.Panel.__init__(self, parent, -1, style=wx.WANTS_CHARS)
# Now that the list exists we can init the other base class,
# see wxPython/lib/mixins/listctrl.py
self.itemDataMap = musicdata
- listmix.wxColumnSorterMixin.__init__(self, 3)
+ listmix.ColumnSorterMixin.__init__(self, 3)
#self.SortListItems(0, True)
self.Bind(wx.EVT_SIZE, self.OnSize)
self.currentItem = 0
- # Used by the wxColumnSorterMixin, see wxPython/lib/mixins/listctrl.py
+ # Used by the ColumnSorterMixin, see wxPython/lib/mixins/listctrl.py
def GetListCtrl(self):
return self.list
- # Used by the wxColumnSorterMixin, see wxPython/lib/mixins/listctrl.py
+ # Used by the ColumnSorterMixin, see wxPython/lib/mixins/listctrl.py
def GetSortImages(self):
return (self.sm_dn, self.sm_up)
<h4>ListCtrlAutoWidthMixin</h4>
-<code><b>wxListCtrlAutoWidthMixin()</b></code>
+<code><b>ListCtrlAutoWidthMixin()</b></code>
<p>A mix-in class that automatically resizes the last column to take up the
remaining width of the ListCtrl.
#
# o Library must be updated for this to run.
#
+# 12/20/2003 - Jeff Grimmett (grimmtooth@softhome.net)
+#
+# o wxMVCTree -> MVCTree
+#
import os
import sys
logger.write("Delete\n")
def runTest(frame, nb, log):
- #f = wx.Frame(frame, -1, "wxMVCTree", (0,0), (200,500))
+ #f = wx.Frame(frame, -1, "MVCTree", (0,0), (200,500))
global logger
logger = log
- p = tree.wxMVCTree(nb, -1)
- #f = wx.Frame(frame, -1, "wxMVCTree")
- #p = tree.wxMVCTree(f, -1)
+ p = tree.MVCTree(nb, -1)
+ #f = wx.Frame(frame, -1, "MVCTree")
+ #p = tree.MVCTree(f, -1)
p.SetAssumeChildren(True)
p.SetModel(tree.LateFSTreeModel(os.path.normpath(os.getcwd() + os.sep +'..')))
overview = """\
-wxMVCTree is a control which handles hierarchical data. It is
+MVCTree is a control which handles hierarchical data. It is
constructed in model-view-controller architecture, so the display of
that data, and the content of the data can be changed greatly without
affecting the other parts.
#
# o Issues with lib corrected.
#
+# 12/20/2003 - Jeff Grimmett (grimmtooth@softhome.net)
+#
+# o wxMaskedNumCtrl -> MaskedNumCtrl
+#
import string
import sys
panel = wx.Panel( self, -1 )
header = wx.StaticText(panel, -1, """\
-This shows the various options for wxMaskedNumCtrl.
+This shows the various options for MaskedNumCtrl.
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.wxMaskedNumCtrl(
+ self.integerwidth = mnum.MaskedNumCtrl(
panel, value=10, integerWidth=2, allowNegative=False
)
fraclabel = wx.StaticText( panel, -1, "Fraction width:" )
- self.fractionwidth = mnum.wxMaskedNumCtrl(
+ self.fractionwidth = mnum.MaskedNumCtrl(
panel, value=0, integerWidth=2, allowNegative=False
)
groupcharlabel = wx.StaticText( panel,-1, "Grouping char:" )
- self.groupchar = mnum.wxMaskedTextCtrl(
+ self.groupchar = mnum.MaskedTextCtrl(
panel, -1, value=',', mask='&', excludeChars = '-()',
formatcodes='F', emptyInvalid=True, validRequired=True
)
decimalcharlabel = wx.StaticText( panel,-1, "Decimal char:" )
- self.decimalchar = mnum.wxMaskedTextCtrl(
+ self.decimalchar = mnum.MaskedTextCtrl(
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.wxMaskedNumCtrl( panel, integerWidth=5, fractionWidth=2 )
+ self.min = mnum.MaskedNumCtrl( panel, integerWidth=5, fractionWidth=2 )
self.min.Enable( False )
self.set_max = wx.CheckBox( panel, -1, "Set maximum value:" )
- self.max = mnum.wxMaskedNumCtrl( panel, integerWidth=5, fractionWidth=2 )
+ self.max = mnum.MaskedNumCtrl( panel, integerWidth=5, fractionWidth=2 )
self.max.Enable( False )
font.SetWeight(wx.BOLD)
label.SetFont(font)
- self.target_ctl = mnum.wxMaskedNumCtrl( panel, -1, name="target control" )
+ self.target_ctl = mnum.MaskedNumCtrl( panel, -1, name="target control" )
label_numselect = wx.StaticText( panel, -1, """\
Programmatically set the above
#
# o renamer issue shelved.
#
+# 12/20/2003 - Jeff Grimmett (grimmtooth@softhome.net)
+#
+# o wxMultiSash -> MultiSash
+#
import wx
import wx.lib.multisash as sash
def runTest(frame, nb, log):
- multi = sash.wxMultiSash(nb, -1, pos = (0,0), size = (640,480))
+ multi = sash.MultiSash(nb, -1, pos = (0,0), size = (640,480))
# Use this method to set the default class that will be created when
# a new sash is created. The class's constructor needs 1 parameter
overview = """<html><body>
-<h2><center>wxMultiSash</center></h2>
+<h2><center>MultiSash</center></h2>
-wxMultiSash allows the user to split a window any number of times
+MultiSash allows the user to split a window any number of times
either horizontally or vertically, and to close the split off windows
when desired.
#
# 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.wxPopupControl):
+class TestDateControl(pop.PopupControl):
def __init__(self,*_args,**_kwargs):
- apply(pop.wxPopupControl.__init__,(self,) + _args,_kwargs)
+ apply(pop.PopupControl.__init__,(self,) + _args,_kwargs)
self.win = wx.Window(self,-1,pos = (0,0),style = 0)
self.cal = cal.CalendarCtrl(self.win,-1,pos = (0,0))
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):
#----------------------------------------------------------------------
overview = """<html><body>
-<h2><center>wxPopupControl</center></h2>
+<h2><center>PopupControl</center></h2>
-wxPopupControl is a class that can display a value and has a button
+PopupControl is a class that can display a value and has a button
that will popup another window similar to how a wxComboBox works. The
popup window can contain whatever is needed to edit the value. This
example uses a wxCalendarCtrl.
#
# o Updated URL for SF link in overview.
#
+# 12/21/2003 - Jeff Grimmett (grimmtooth@softhome.net)
+#
+# o wxPyColorChooser -> PyColorChooser
+# o wxPyColourChooser -> PyColourChooser
+#
import wx
import wx.lib.colourchooser as cc
wx.Panel.__init__(self, parent, -1)
self.log = log
- chooser = cc.wxPyColourChooser(self, -1)
+ chooser = cc.PyColourChooser(self, -1)
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(chooser, 0, wx.ALL, 25)
#---------------------------------------------------------------
overview = """
-The wxPyColourChooser component creates a colour chooser window
+The PyColourChooser component creates a colour chooser window
that is similar to the Microsoft Windows colour chooser dialog.
This dialog component is drawn in a panel, and thus can be
embedded inside any widget (although it cannot be resized).
How to use it
------------------------------
-The demo (demo/wxPyColourChooser.py code shows how to display
+The demo (demo/PyColourChooser.py code shows how to display
a colour chooser and retrieve its options.
Contact and Author Info
------------------------------
-wxPyColourChooser was written and is maintained by:
+PyColourChooser was written and is maintained by:
Michael Gilfix <mgilfix@eecs.tufts.edu>
-You can find the latest wxPyColourChooser code at
+You can find the latest PyColourChooser code at
http://sourceforge.net/projects/wxcolourchooser/. If you have
any suggestions or want to submit a patch, please send
it my way at: mgilfix@eecs.tufts.edu
#
# o All issues resolved.
#
-
+# 12/20/2003 - Jeff Grimmett (grimmtooth@softhome.net)
+#
+# o wxRightTextCtrl -> RightTextCtrl
+#
############################################################################\
# Note: this demo has been converted, but the control is deprecated because |
)
fgs.Add(txt)
- fgs.Add(right.wxRightTextCtrl(self, -1, "", size=(75, -1)))
+ fgs.Add(right.RightTextCtrl(self, -1, "", size=(75, -1)))
fgs.Add((10,10))
- fgs.Add(right.wxRightTextCtrl(self, -1, "123.45", size=(75, -1)))
+ fgs.Add(right.RightTextCtrl(self, -1, "123.45", size=(75, -1)))
fgs.Add((10,10))
- fgs.Add(right.wxRightTextCtrl(self, -1, "234.56", size=(75, -1)))
+ fgs.Add(right.RightTextCtrl(self, -1, "234.56", size=(75, -1)))
fgs.Add((10,10))
- fgs.Add(right.wxRightTextCtrl(self, -1, "345.67", size=(75, -1)))
+ fgs.Add(right.RightTextCtrl(self, -1, "345.67", size=(75, -1)))
fgs.Add((10,10))
- fgs.Add(right.wxRightTextCtrl(self, -1, "456.78", size=(75, -1)))
+ fgs.Add(right.RightTextCtrl(self, -1, "456.78", size=(75, -1)))
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(fgs, 0, wx.ALL, 25)
#
# o lib updated, all is well.
#
+# 12/21/2003 - Jeff Grimmett (grimmtooth@softhome.net)
+#
+# o wxScrolledPanel -> ScrolledPanel
+#
import wx
import wx.lib.scrolledpanel as scrolled
text = "one two buckle my shoe three four shut the door five six pick up sticks seven eight lay them straight nine ten big fat hen"
-class TestPanel(scrolled.wxScrolledPanel):
+class TestPanel(scrolled.ScrolledPanel):
def __init__(self, parent, log):
self.log = log
- scrolled.wxScrolledPanel.__init__(self, parent, -1)
+ scrolled.ScrolledPanel.__init__(self, parent, -1)
vbox = wx.BoxSizer(wx.VERTICAL)
desc = wx.StaticText(self, -1,
- "wxScrolledPanel extends wxScrolledWindow, adding all "
+ "ScrolledPanel extends wxScrolledWindow, adding all "
"the necessary bits to set up scroll handling for you.\n\n"
"Here are three fixed size examples of its use. The "
"demo panel for this sample is also using it -- the \nwxStaticLine"
words = text.split()
- panel1 = scrolled.wxScrolledPanel(self, -1, size=(120,300),
+ panel1 = scrolled.ScrolledPanel(self, -1, size=(120,300),
style = wx.TAB_TRAVERSAL|wx.SUNKEN_BORDER )
fgs1 = wx.FlexGridSizer(cols=2, vgap=4, hgap=4)
panel1.SetAutoLayout(1)
panel1.SetupScrolling( scroll_x=False )
- panel2 = scrolled.wxScrolledPanel(self, -1, size=(350, 40),
+ panel2 = scrolled.ScrolledPanel(self, -1, size=(350, 40),
style = wx.TAB_TRAVERSAL|wx.SUNKEN_BORDER)
- panel3 = scrolled.wxScrolledPanel(self, -1, size=(200,100),
+ panel3 = scrolled.ScrolledPanel(self, -1, size=(200,100),
style = wx.TAB_TRAVERSAL|wx.SUNKEN_BORDER)
fgs2 = wx.FlexGridSizer(cols=25, vgap=4, hgap=4)
overview = """<html><body>
-wxScrolledPanel fills a "hole" in the implementation of wxScrolledWindow,
+ScrolledPanel fills a "hole" in the implementation of wxScrolledWindow,
providing automatic scrollbar and scrolling behavior and the tab traversal
mangement that wxScrolledWindow lacks.
</body></html>
#
# 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
#----------------------------------------------------------------------
-class TestPanel( scrolled.wxScrolledPanel ):
+class TestPanel( scrolled.ScrolledPanel ):
def __init__( self, parent, log ):
- scrolled.wxScrolledPanel.__init__( self, parent, -1 )
+ scrolled.ScrolledPanel.__init__( self, parent, -1 )
self.log = log
text1 = wx.StaticText( self, -1, "12-hour format:")
- self.time12 = timectl.wxTimeCtrl( self, -1, name="12 hour control" )
+ self.time12 = timectl.TimeCtrl( self, -1, name="12 hour control" )
spin1 = wx.SpinButton( self, -1, wx.DefaultPosition, (-1,20), 0 )
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.wxTimeCtrl(
+ self.time24 = timectl.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.wxTimeCtrl(
+ self.spinless_ctrl = timectl.TimeCtrl(
self, -1, name="spinless control",
display_seconds = False
)
self.set_bounds = wx.CheckBox( self, -1, "Set time bounds:" )
minlabel = wx.StaticText( self, -1, "minimum time:" )
- self.min = timectl.wxTimeCtrl( self, -1, name="min", display_seconds = False )
+ self.min = timectl.TimeCtrl( self, -1, name="min", display_seconds = False )
self.min.Enable( False )
maxlabel = wx.StaticText( self, -1, "maximum time:" )
- self.max = timectl.wxTimeCtrl( self, -1, name="max", display_seconds = False )
+ self.max = timectl.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.wxTimeCtrl( self, -1, name="new" )
+ self.target_ctrl = timectl.TimeCtrl( self, -1, name="new" )
grid2 = wx.FlexGridSizer( 0, 2, 0, 0 )
grid2.Add( (20, 0), 0, wx.ALIGN_LEFT|wx.ALL, 5 )
"""
-wxPyColourChooser
+PyColourChooser
Copyright (C) 2002 Michael Gilfix <mgilfix@eecs.tufts.edu>
-This file is part of wxPyColourChooser.
+This file is part of PyColourChooser.
-This version of wxPyColourChooser is open source; you can redistribute it
+This version of PyColourChooser is open source; you can redistribute it
and/or modify it under the licensed terms.
This program is distributed in the hope that it will be useful,
#
# o 2.5 compatability update.
#
+# 12/21/2003 - Jeff Grimmett (grimmtooth@softhome.net)
+#
+# o wxPyColorChooser -> PyColorChooser
+# o wxPyColourChooser -> PyColourChooser
+#
from pycolourchooser import *
# For the American in you
-wxPyColorChooser = wxPyColourChooser
+PyColorChooser = PyColourChooser
__all__ = [
'canvas',
"""
-wxPyColourChooser
+PyColourChooser
Copyright (C) 2002 Michael Gilfix <mgilfix@eecs.tufts.edu>
-This file is part of wxPyColourChooser.
+This file is part of PyColourChooser.
-This version of wxPyColourChooser is open source; you can redistribute it
+This version of PyColourChooser is open source; you can redistribute it
and/or modify it under the licensed terms.
This program is distributed in the hope that it will be useful,
#
# o 2.5 compatability update.
#
+# 12/21/2003 - Jeff Grimmett (grimmtooth@softhome.net)
+#
+# o wxPyColorChooser -> PyColorChooser
+# o wxPyColourChooser -> PyColourChooser
+#
import wx
"""
-wxPyColourChooser
+PyColourChooser
Copyright (C) 2002 Michael Gilfix <mgilfix@eecs.tufts.edu>
-This file is part of wxPyColourChooser.
+This file is part of PyColourChooser.
-This version of wxPyColourChooser is open source; you can redistribute it
+This version of PyColourChooser is open source; you can redistribute it
and/or modify it under the licensed terms.
This program is distributed in the hope that it will be useful,
try:
import gettext
- gettext.bindtextdomain('wxpycolourchooser')
- gettext.textdomain('wxpycolourchooser')
+ gettext.bindtextdomain('pycolourchooser')
+ gettext.textdomain('pycolourchooser')
_ = gettext.gettext
except Exception, strerror:
print "Warning: Couldn't import translation function: %(str)s" %{ 'str' : strerror }
"""
-wxPyColourChooser
+PyColourChooser
Copyright (C) 2002 Michael Gilfix <mgilfix@eecs.tufts.edu>
-This file is part of wxPyColourChooser.
+This file is part of PyColourChooser.
-This version of wxPyColourChooser is open source; you can redistribute it
+This version of PyColourChooser is open source; you can redistribute it
and/or modify it under the licensed terms.
This program is distributed in the hope that it will be useful,
#
# o 2.5 compatability update.
#
+# 12/21/2003 - Jeff Grimmett (grimmtooth@softhome.net)
+#
+# o wxPyColorChooser -> PyColorChooser
+# o wxPyColourChooser -> PyColourChooser
+#
import wx
"""
-wxPyColourChooser
+PyColourChooser
Copyright (C) 2002 Michael Gilfix <mgilfix@eecs.tufts.edu>
-This file is part of wxPyColourChooser.
+This file is part of PyColourChooser.
-This version of wxPyColourChooser is open source; you can redistribute it
+This version of PyColourChooser is open source; you can redistribute it
and/or modify it under the licensed terms.
This program is distributed in the hope that it will be useful,
#
# o 2.5 compatability update.
#
+# 12/21/2003 - Jeff Grimmett (grimmtooth@softhome.net)
+#
+# o wxPyColorChooser -> PyColorChooser
+# o wxPyColourChooser -> PyColourChooser
+# o Added wx.InitAllImageHandlers() to test code since
+# that's where it belongs.
+#
import wx
from intl import _ # _
-class wxPyColourChooser(wx.Panel):
+class PyColourChooser(wx.Panel):
"""A Pure-Python implementation of the colour chooser dialog.
The PyColourChooser is a pure python implementation of the colour
def OnInit(self):
frame = wx.Frame(None, -1, 'PyColourChooser Test')
- chooser = wxPyColourChooser(frame, -1)
+ # Added here because that's where it's supposed to be,
+ # not embedded in the library. If it's embedded in the
+ # library, debug messages will be generated for duplicate
+ # handlers.
+ wx.InitAllImageHandlers()
+
+ chooser = PyColourChooser(frame, -1)
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(chooser, 0, 0)
frame.SetAutoLayout(True)
"""
-wxPyColourChooser
+PyColourChooser
Copyright (C) 2002 Michael Gilfix
-This file is part of wxPyColourChooser.
+This file is part of PyColourChooser.
You should have received a file COPYING containing license terms
along with this program; if not, write to Michael Gilfix
(mgilfix@eecs.tufts.edu) for a copy.
-This version of wxPyColourChooser is open source; you can redistribute it and/or
+This version of PyColourChooser is open source; you can redistribute it and/or
modify it under the terms listed in the file COPYING.
This program is distributed in the hope that it will be useful,
#
# o 2.5 compatability update.
#
+# 12/21/2003 - Jeff Grimmett (grimmtooth@softhome.net)
+#
+# o wxPyColorChooser -> PyColorChooser
+# o wxPyColourChooser -> PyColourChooser
+#
import wx
"""
-wxPyColourChooser
+PyColourChooser
Copyright (C) 2002 Michael Gilfix
-This file is part of wxPyColourChooser.
+This file is part of PyColourChooser.
You should have received a file COPYING containing license terms
along with this program; if not, write to Michael Gilfix
(mgilfix@eecs.tufts.edu) for a copy.
-This version of wxPyColourChooser is open source; you can redistribute it and/or
+This version of PyColourChooser is open source; you can redistribute it and/or
modify it under the terms listed in the file COPYING.
This program is distributed in the hope that it will be useful,
#
# o 2.5 compatability update.
#
+# 12/21/2003 - Jeff Grimmett (grimmtooth@softhome.net)
+#
+# o wxPyColorChooser -> PyColorChooser
+# o wxPyColourChooser -> PyColourChooser
+# o Commented out wx.InitAllImageHandlers() (see comments at that
+# point for explanation
+#
import cStringIO
import zlib
def __init__(self, parent, id):
"""Creates a palette object."""
# Load the pre-generated palette XPM
- wx.InitAllImageHandlers()
+
+ # Leaving this in causes warning messages in some cases.
+ # It is the responsibility of the app to init the image
+ # handlers, IAW RD
+ #wx.InitAllImageHandlers()
+
self.palette = getBitmap ()
canvas.Canvas.__init__ (self, parent, id, size=(200, 192))
#
# o 2.5 compatability update.
#
+# 12/21/2003 - Jeff Grimmett (grimmtooth@softhome.net)
+#
+# o wxEditor -> Editor
+#
# This file makes this directory into a Python package
# import the main classes into the package namespace.
-from editor import wxEditor
+from editor import Editor
#----------------------------------------------------------------------
-# Name: wxPython.lib.editor.wxEditor
+# Name: wxPython.lib.editor.Editor
# Purpose: An intelligent text editor with colorization capabilities.
#
# Original
#
# o 2.5 compatability update.
#
+# 12/21/2003 - Jeff Grimmett (grimmtooth@softhome.net)
+#
+# o wxEditor -> Editor
+#
import os
import time
#----------------------------------------------------------------------
-class wxEditor(wx.ScrolledWindow):
+class Editor(wx.ScrolledWindow):
def __init__(self, parent, id,
pos=wx.DefaultPosition, size=wx.DefaultSize, style=0):
#
# o 2.5 Compatability changes
#
+# 12/20/2003 - Jeff Grimmett (grimmtooth@softhome.net)
+#
+# o In keeping with the common idiom, the sizers in this module
+# have been given the 'Py' prefix to avoid confusion with the
+# native sizers of the same name. However, the reverse renamer
+# still has the old wx*Sizer since the whole point of the
+# reverse renamer is backward compatability.
+# o wxGridSizer -> PyGridSizer
+# o wxFlexGridSizer -> PyFlexGridSizer
+# o Deprecation warning added.
+#
"""
-In this module you will find wxGridSizer and wxFlexGridSizer. Please
-note that these sizers have since been ported to C++ and those
-versions are now exposed in the regular wxPython wrappers. However I
-am also leaving them here in the library so they can serve as an
-example of how to implement sizers in Python.
+In this module you will find PyGridSizer and PyFlexGridSizer. Please
+note that these sizers have since been ported to C++ (as wx.GridSizer
+and wx.FlexGridSizer) and those versions are now exposed in the regular
+wxPython wrappers. However I am also leaving them here in the library
+so they can serve as an example of how to implement sizers in Python.
-wxGridSizer: Sizes and positions items such that all rows are the same
+PyGridSizer: Sizes and positions items such that all rows are the same
height and all columns are the same width. You can specify a gap in
pixels to be used between the rows and/or the columns. When you
create the sizer you specify the number of rows or the number of
resized the same amount so all rows and all columns remain the same
size.
-wxFlexGridSizer: Derives from wxGridSizer and adds the ability for
+PyFlexGridSizer: Derives from PyGridSizer and adds the ability for
particular rows and/or columns to be marked as growable. This means
that when the sizer changes size, the growable rows and colums are the
ones that stretch. The others remain at their initial size.
import operator
+import warnings
import wx
+warningmsg = r"""\
+
+################################################\
+# THIS MODULE IS DEPRECATED |
+# |
+# You should use the native wx.GridSizer and |
+# wx.FlexGridSizer unless there is a compelling |
+# need to use this module. |
+################################################/
+
+
+"""
+
+warnings.warn(warningmsg, DeprecationWarning, stacklevel=2)
+
+
#----------------------------------------------------------------------
-class wxGridSizer(wx.PySizer):
+class PyGridSizer(wx.PySizer):
def __init__(self, rows=0, cols=0, hgap=0, vgap=0):
wx.PySizer.__init__(self)
if rows == 0 and cols == 0:
-class wxFlexGridSizer(wxGridSizer):
+class PyFlexGridSizer(wxGridSizer):
def __init__(self, rows=0, cols=0, hgap=0, vgap=0):
wxGridSizer.__init__(self, rows, cols, hgap, vgap)
self.rowHeights = []
self.y_pos = 20
self.delta = 20
- size = wxSize(80, 25)
+ size = wx.Size(80, 25)
self.set_dir = os.getcwd()
self.set_file = None
+# 12/20/2003 - Jeff Grimmett (grimmtooth@softhome.net)
+#
+# o wxPyInformationalMessagesFrame -> PyInformationalMessagesFrame
+# o dummy_wxPyInformationalMessagesFrame -> dummy_PyInformationalMessagesFrame
+#
+
"""
infoframe.py
Released under wxWindows license etc.
from wxPython.lib.infoframe import *
... # ... modify your wxApp as follows:
class myApp(wxApp):
- outputWindowClass = wxPyInformationalMessagesFrame
+ outputWindowClass = PyInformationalMessagesFrame
...
If you're running on Linux, you'll also have to supply an argument 1 to your
constructor of myApp to redirect stdout/stderr to this window (it's done
If you don't want to redirect stdout/stderr, but use the class directly: do
it this way:
- InformationalMessagesFrame = wxPyInformationalMessagesFrame\
+ InformationalMessagesFrame = PyInformationalMessagesFrame\
([options from progname (default ""),
txt (default "informational
messages"])
-class wxPyInformationalMessagesFrame:
+class PyInformationalMessagesFrame:
def __init__(self,
progname="",
text="informational messages",
-class Dummy_wxPyInformationalMessagesFrame:
+class Dummy_PyInformationalMessagesFrame:
def __init__(self,progname=""):
self.softspace = 1
def __call__(self,*args):
# NOTE:
# This was written to provide a standard integer edit control for wxPython.
#
-# wxIntCtrl permits integer (long) values to be retrieved or set via
+# IntCtrl permits integer (long) values to be retrieved or set via
# .GetValue() and .SetValue(), and provides an EVT_INT() event function
# for trapping changes to the control.
#
# contents of the control with '-' will result in a selected (absolute)
# value of -1.
#
-# wxIntCtrl also supports range limits, with the option of either
+# IntCtrl also supports range limits, with the option of either
# enforcing them or simply coloring the text of the control if the limits
# are exceeded.
#----------------------------------------------------------------------------
#
# o 2.5 Compatability changes
#
+# 12/20/2003 - Jeff Grimmett (grimmtooth@softhome.net)
+#
+# o wxIntUpdateEvent -> IntUpdateEvent
+# o wxIntValidator -> IntValidator
+# o wxIntCtrl -> IntCtrl
+#
import string
import types
WXK_CTRL_X = (ord('X')+1) - ord('A')
WXK_CTRL_V = (ord('V')+1) - ord('A')
-class wxIntUpdatedEvent(wx.PyCommandEvent):
+class IntUpdatedEvent(wx.PyCommandEvent):
def __init__(self, id, value = 0, object=None):
wx.PyCommandEvent.__init__(self, wxEVT_COMMAND_INT_UPDATED, id)
#----------------------------------------------------------------------------
-class wxIntValidator( wx.PyValidator ):
+class IntValidator( wx.PyValidator ):
"""
- Validator class used with wxIntCtrl; handles all validation of input
+ Validator class used with IntCtrl; handles all validation of input
prior to changing the value of the underlying wx.TextCtrl.
"""
def __init__(self):
#----------------------------------------------------------------------------
-class wxIntCtrl(wx.TextCtrl):
+class IntCtrl(wx.TextCtrl):
"""
This class provides a control that takes and returns integers as
value, and provides bounds support and optional value limiting.
- wxIntCtrl(
+ IntCtrl(
parent, id = -1,
value = 0,
pos = wxDefaultPosition,
when the bounds are set but the control is not limited.
validator
- Normally None, wxIntCtrl uses its own validator to do value
+ Normally None, IntCtrl uses its own validator to do value
validation and input control. However, a validator derived
- from wxIntValidator can be supplied to override the data
- transfer methods for the wxIntValidator class.
+ from IntValidator can be supplied to override the data
+ transfer methods for the IntValidator class.
"""
def __init__ (
self.__oldvalue = None
if validator == wx.DefaultValidator:
- validator = wxIntValidator()
+ validator = IntValidator()
wx.TextCtrl.__init__(
self, parent, id, self._toGUI(0),
if value != self.__oldvalue:
try:
self.GetEventHandler().ProcessEvent(
- wxIntUpdatedEvent( self.GetId(), self.GetValue(), self ) )
+ IntUpdatedEvent( self.GetId(), self.GetValue(), self ) )
except ValueError:
return
# let normal processing of the text continue
if( not (value is None and self.IsNoneAllowed())
and type(value) not in (types.IntType, types.LongType) ):
raise ValueError (
- 'wxIntCtrl requires integer values, passed %s'% repr(value) )
+ 'IntCtrl requires integer values, passed %s'% repr(value) )
min = self.GetMin()
max = self.GetMax()
return ''
elif type(value) == types.LongType and not self.IsLongAllowed():
raise ValueError (
- 'wxIntCtrl requires integer value, passed long' )
+ 'IntCtrl requires integer value, passed long' )
elif type(value) not in (types.IntType, types.LongType):
raise ValueError (
- 'wxIntCtrl requires integer value, passed %s'% repr(value) )
+ 'IntCtrl requires integer value, passed %s'% repr(value) )
elif self.IsLimited():
min = self.GetMin()
style = wx.DEFAULT_DIALOG_STYLE ):
wx.Dialog.__init__(self, parent, id, title, pos, size, style)
- self.int_ctrl = wxIntCtrl(self, wx.NewId(), size=(55,20))
+ self.int_ctrl = IntCtrl(self, wx.NewId(), size=(55,20))
self.OK = wx.Button( self, wx.ID_OK, "OK")
self.Cancel = wx.Button( self, wx.ID_CANCEL, "Cancel")
return True
def OnClick(self, event):
- dlg = myDialog(self.panel, -1, "test wxIntCtrl")
+ dlg = myDialog(self.panel, -1, "test IntCtrl")
dlg.int_ctrl.SetValue(501)
dlg.int_ctrl.SetInsertionPoint(1)
dlg.int_ctrl.SetSelection(1,2)
#
# o Updated for wx namespace (minor)
#
+# 12/20/2003 - Jeff Grimmett (grimmtooth@softhome.net)
+#
+# o Removed wx prefix
+#
"""<html><body>
<P>
-<B>wxMaskedCtrl</B> is actually a factory function for several types of
+<B>MaskedCtrl</B> is actually a factory function for several types of
masked edit controls:
<P>
<UL>
- <LI><b>wxMaskedTextCtrl</b> - standard masked edit text box</LI>
- <LI><b>wxMaskedComboBox</b> - adds combobox capabilities</LI>
- <LI><b>wxIpAddrCtrl</b> - adds logical input semantics for IP address entry</LI>
- <LI><b>wxTimeCtrl</b> - special subclass handling lots of time formats as values</LI>
- <LI><b>wxMaskedNumCtrl</b> - special subclass handling numeric values</LI>
+ <LI><b>MaskedTextCtrl</b> - standard masked edit text box</LI>
+ <LI><b>MaskedComboBox</b> - adds combobox capabilities</LI>
+ <LI><b>IpAddrCtrl</b> - adds logical input semantics for IP address entry</LI>
+ <LI><b>TimeCtrl</b> - special subclass handling lots of time formats as values</LI>
+ <LI><b>MaskedNumCtrl</b> - special subclass handling numeric values</LI>
</UL>
<P>
-<B>wxMaskedCtrl</B> works by looking for a special <b><i>controlType</i></b>
+<B>MaskedCtrl</B> works by looking for a special <b><i>controlType</i></b>
parameter in the variable arguments of the control, to determine
what kind of instance to return.
controlType can be one of:
These constants are also available individually, ie, you can
use either of the following:
<PRE><FONT SIZE=-1>
- from wxPython.wx.lib.maskedctrl import wxMaskedCtrl, MASKEDCOMBO, MASKEDTEXT, NUMBER
- from wxPython.wx.lib.maskedctrl import wxMaskedCtrl, controlTypes
+ from wxPython.wx.lib.maskedctrl import MaskedCtrl, MASKEDCOMBO, MASKEDTEXT, NUMBER
+ from wxPython.wx.lib.maskedctrl import MaskedCtrl, controlTypes
</FONT></PRE>
If not specified as a keyword argument, the default controlType is
controlTypes.MASKEDTEXT.
<P>
-Each of the above classes has its own unique arguments, but wxMaskedCtrl
-provides a single "unified" interface for masked controls. wxMaskedTextCtrl,
-wxMaskedComboBox and wxIpAddrCtrl are all documented below; the others have
+Each of the above classes has its own unique arguments, but MaskedCtrl
+provides a single "unified" interface for masked controls. MaskedTextCtrl,
+MaskedComboBox and IpAddrCtrl are all documented below; the others have
their own demo pages and interface descriptions.
</body></html>
"""
-from wx.lib.maskededit import wxMaskedTextCtrl, wxMaskedComboBox, wxIpAddrCtrl
-from wx.lib.maskednumctrl import wxMaskedNumCtrl
-from wx.lib.timectrl import wxTimeCtrl
+from wx.lib.maskededit import MaskedTextCtrl, MaskedComboBox, IpAddrCtrl
+from wx.lib.maskednumctrl import MaskedNumCtrl
+from wx.lib.timectrl import TimeCtrl
# "type" enumeration for class instance factory function
NUMBER = NUMBER
-def wxMaskedCtrl( *args, **kwargs):
+def MaskedCtrl( *args, **kwargs):
"""
Actually a factory function providing a unifying
interface for generating masked controls.
del kwargs['controlType']
if controlType == MASKEDTEXT:
- return wxMaskedTextCtrl(*args, **kwargs)
+ return MaskedTextCtrl(*args, **kwargs)
elif controlType == MASKEDCOMBO:
- return wxMaskedComboBox(*args, **kwargs)
+ return MaskedComboBox(*args, **kwargs)
elif controlType == IPADDR:
- return wxIpAddrCtrl(*args, **kwargs)
+ return IpAddrCtrl(*args, **kwargs)
elif controlType == TIME:
- return wxTimeCtrl(*args, **kwargs)
+ return TimeCtrl(*args, **kwargs)
elif controlType == NUMBER:
- return wxMaskedNumCtrl(*args, **kwargs)
+ return MaskedNumCtrl(*args, **kwargs)
else:
raise AttributeError(
# This was written way it is because of the lack of masked edit controls
# in wxWindows/wxPython.
#
-# wxMaskedEdit controls are based on a suggestion made on [wxPython-Users] by
+# MaskedEdit controls are based on a suggestion made on [wxPython-Users] by
# Jason Hihn, and borrows liberally from Will Sadkin's original masked edit
-# control for time entry, wxTimeCtrl (which is now rewritten using this
+# control for time entry, TimeCtrl (which is now rewritten using this
# control!).
#
-# wxMaskedEdit controls do not normally use validators, because they do
+# MaskedEdit controls do not normally use validators, because they do
# careful manipulation of the cursor in the text window on each keystroke,
# and validation is cursor-position specific, so the control intercepts the
# key codes before the validator would fire. However, validators can be
#
# o Missed wx.DateTime stuff earlier.
#
+# 12/20/2003 - Jeff Grimmett (grimmtooth@softhome.net)
+#
+# o wxMaskedEditMixin -> MaskedEditMixin
+# o wxMaskedTextCtrl -> MaskedTextCtrl
+# o wxMaskedComboBoxSelectEvent -> MaskedComboBoxSelectEvent
+# o wxMaskedComboBox -> MaskedComboBox
+# o wxIpAddrCtrl -> IpAddrCtrl
+# o wxTimeCtrl -> TimeCtrl
+#
"""\
<b>Masked Edit Overview:
=====================</b>
-<b>wxMaskedTextCtrl</b>
+<b>MaskedTextCtrl</b>
is a sublassed text control that can carefully control the user's input
based on a mask string you provide.
General usage example:
- control = wxMaskedTextCtrl( win, -1, '', mask = '(###) ###-####')
+ control = MaskedTextCtrl( win, -1, '', mask = '(###) ###-####')
The example above will create a text control that allows only numbers to be
entered and then only in the positions indicated in the mask by the # sign.
-<b>wxMaskedComboBox</b>
+<b>MaskedComboBox</b>
is a similar subclass of wxComboBox that allows the same sort of masking,
but also can do auto-complete of values, and can require the value typed
to be in the list of choices to be colored appropriately.
<b>wxMaskedCtrl</b>
is actually a factory function for several types of masked edit controls:
- <b>wxMaskedTextCtrl</b> - standard masked edit text box
- <b>wxMaskedComboBox</b> - adds combobox capabilities
- <b>wxIpAddrCtrl</b> - adds special semantics for IP address entry
- <b>wxTimeCtrl</b> - special subclass handling lots of types as values
+ <b>MaskedTextCtrl</b> - standard masked edit text box
+ <b>MaskedComboBox</b> - adds combobox capabilities
+ <b>IpAddrCtrl</b> - adds special semantics for IP address entry
+ <b>TimeCtrl</b> - special subclass handling lots of types as values
<b>wxMaskedNumCtrl</b> - special subclass handling numeric values
It works by looking for a <b><i>controlType</i></b> parameter in the keyword
arguments of the control, to determine what kind of instance to return.
If not specified as a keyword argument, the default control type returned
- will be wxMaskedTextCtrl.
+ will be MaskedTextCtrl.
Each of the above classes has its own set of arguments, but wxMaskedCtrl
provides a single "unified" interface for masked controls. Those for
- wxMaskedTextCtrl, wxMaskedComboBox and wxIpAddrCtrl are all documented
+ MaskedTextCtrl, MaskedComboBox and IpAddrCtrl are all documented
below; the others have their own demo pages and interface descriptions.
(See end of following discussion for how to configure the wxMaskedCtrl()
to select the above control types.)
choices= A list of strings that are allowed choices for the control.
choiceRequired= value must be member of choices list
compareNoCase= Perform case-insensitive matching when validating against list
- <i>Note: for wxMaskedComboBox, this defaults to True.</i>
+ <i>Note: for MaskedComboBox, this defaults to True.</i>
emptyInvalid= Boolean indicating whether an empty value should be considered invalid
validFunc= A function to call of the form: bool = func(candidate_value)
after construction; it takes a list of key/value pairs as arguments,
where the keys can be any of the mask-specific parameters in the constructor.
Eg:
- ctl = wxMaskedTextCtrl( self, -1 )
+ ctl = MaskedTextCtrl( self, -1 )
ctl.SetCtrlParameters( mask='###-####',
defaultValue='555-1212',
formatcodes='F')
The following methods must be used and/or defined when deriving a control
from wxMaskedEditMixin. NOTE: if deriving from a *masked edit* control
- (eg. class wxIpAddrCtrl(wxMaskedTextCtrl) ), then this is NOT necessary,
+ (eg. class IpAddrCtrl(MaskedTextCtrl) ), then this is NOT necessary,
as it's already been done for you in the base class.
._SetInitialValue()
Similarly to _GetSelection, each class derived from
wxMaskedEditMixin must define the function for setting
the start and end of the current text selection.
- (eg. .SetSelection() for wxMaskedTextCtrl, and .SetMark() for
- wxMaskedComboBox.
+ (eg. .SetSelection() for MaskedTextCtrl, and .SetMark() for
+ MaskedComboBox.
._GetInsertionPoint()
._SetInsertionPoint()
._IsEditable() REQUIRED
Each class derived from wxMaskedEditMixin must define
the function used to determine if the base control is
- editable or not. (For wxMaskedComboBox, this has to
+ editable or not. (For MaskedComboBox, this has to
be done with code, rather than specifying the proper
function in the base control, as there isn't one...)
._CalcSize() REQUIRED
These 5 handlers must be "wired up" for the wxMaskedEdit
control to provide default behavior. (The setupEventHandling
- is an argument to wxMaskedTextCtrl and wxMaskedComboBox, so
+ is an argument to MaskedTextCtrl and MaskedComboBox, so
that controls derived from *them* may replace one of these
handlers if they so choose.)
._AddNavKeycode(keycode, handler=None)
._AddNavKey(char, handler=None)
Allows controls to specify other keys (and optional handlers)
- to be treated as navigational characters. (eg. '.' in wxIpAddrCtrl)
+ to be treated as navigational characters. (eg. '.' in IpAddrCtrl)
._GetNavKeycodes() Returns the current list of navigational keycodes.
By default, it adjusts the year in date fields if mask is a date,
It can be overridden by a derived class to
adjust the value of the control at that time.
- (eg. wxIpAddrCtrl reformats the address in this way.)
+ (eg. IpAddrCtrl reformats the address in this way.)
._Change() Called by internal EVT_TEXT handler. Return False to force
skip of the normal class change event.
_OnCtrl_Z(event) 'undo' - resets value to previous value (if any)
_OnChangeField(event) primarily used for tab events, but can be
- used for other keys (eg. '.' in wxIpAddrCtrl)
+ used for other keys (eg. '.' in IpAddrCtrl)
_OnErase(event) used for backspace and delete
_OnHome(event)
'excludeChars': am_pm_exclude,
'formatcodes': 'TF!',
'validRegex': '^' + hours + ':' + minutes + ':' + seconds + ' (A|P)M',
- 'description': "HH:MM:SS (A|P)M\n(see wxTimeCtrl)"
+ 'description': "HH:MM:SS (A|P)M\n(see TimeCtrl)"
},
"TIMEHHMM": {
'mask': "##:## AM",
'excludeChars': am_pm_exclude,
'formatcodes': 'TF!',
'validRegex': '^' + hours + ':' + minutes + ' (A|P)M',
- 'description': "HH:MM (A|P)M\n(see wxTimeCtrl)"
+ 'description': "HH:MM (A|P)M\n(see TimeCtrl)"
},
"MILTIMEHHMMSS": {
'mask': "##:##:##",
'formatcodes': 'TF',
'validRegex': '^' + milhours + ':' + minutes + ':' + seconds,
- 'description': "Military HH:MM:SS\n(see wxTimeCtrl)"
+ 'description': "Military HH:MM:SS\n(see TimeCtrl)"
},
"MILTIMEHHMM": {
'mask': "##:##",
'formatcodes': 'TF',
'validRegex': '^' + milhours + ':' + minutes,
- 'description': "Military HH:MM\n(see wxTimeCtrl)"
+ 'description': "Military HH:MM\n(see TimeCtrl)"
},
"USSOCIALSEC": {
'mask': "###-##-####",
'mask': "###.###.###.###",
'formatcodes': 'F_Sr',
'validRegex': "( \d| \d\d|(1\d\d|2[0-4]\d|25[0-5]))(\.( \d| \d\d|(1\d\d|2[0-4]\d|25[0-5]))){3}",
- 'description': "IP Address\n(see wxIpAddrCtrl)"
+ 'description': "IP Address\n(see IpAddrCtrl)"
}
}
## ---------- ---------- ---------- ---------- ---------- ---------- ----------
-class wxMaskedEditMixin:
+class MaskedEditMixin:
"""
This class allows us to abstract the masked edit functionality that could
be associated with any text entry control. (eg. wxTextCtrl, wxComboBox, etc.)
# Validate legitimate set of parameters:
for key in kwargs.keys():
- if key.replace('Color', 'Colour') not in wxMaskedEditMixin.valid_ctrl_params.keys() + Field.valid_params.keys():
+ if key.replace('Color', 'Colour') not in MaskedEditMixin.valid_ctrl_params.keys() + Field.valid_params.keys():
raise TypeError('%s: invalid parameter "%s"' % (name, key))
## Set up dictionary that can be used by subclasses to override or add to default
'&': string.punctuation
}
- ## self._ignoreChange is used by wxMaskedComboBox, because
+ ## self._ignoreChange is used by MaskedComboBox, because
## of the hack necessary to determine the selection; it causes
## EVT_TEXT messages from the combobox to be ignored if set.
self._ignoreChange = False
# Set defaults for each parameter for this instance, and fully
# populate initial parameter list for configuration:
- for key, value in wxMaskedEditMixin.valid_ctrl_params.items():
+ for key, value in MaskedEditMixin.valid_ctrl_params.items():
setattr(self, '_' + key, copy.copy(value))
if not kwargs.has_key(key):
## dbg('%s: "%s"' % (key, repr(value)))
parameters after construction.
"""
dbg(suspend=1)
- dbg('wxMaskedEditMixin::SetCtrlParameters', indent=1)
+ dbg('MaskedEditMixin::SetCtrlParameters', indent=1)
## dbg('kwargs:', indent=1)
## for key, value in kwargs.items():
## dbg(key, '=', value)
ctrl_kwargs = {}
for key, value in kwargs.items():
key = key.replace('Color', 'Colour') # for b-c, and standard wxPython spelling
- if key not in wxMaskedEditMixin.valid_ctrl_params.keys() + Field.valid_params.keys():
+ if key not in MaskedEditMixin.valid_ctrl_params.keys() + Field.valid_params.keys():
dbg(indent=0, suspend=0)
raise TypeError('Invalid keyword argument "%s" for control "%s"' % (key, self.name))
elif key in Field.valid_params.keys():
## dbg(indent=0)
# determine if changing parameters that should affect the entire control:
- for key in wxMaskedEditMixin.valid_ctrl_params.keys():
+ for key in MaskedEditMixin.valid_ctrl_params.keys():
if key in ( 'mask', 'fields' ): continue # (processed separately)
if ctrl_kwargs.has_key(key):
setattr(self, '_' + key, ctrl_kwargs[key])
"""
Routine for retrieving the value of any given parameter
"""
- if wxMaskedEditMixin.valid_ctrl_params.has_key(paramname.replace('Color','Colour')):
+ if MaskedEditMixin.valid_ctrl_params.has_key(paramname.replace('Color','Colour')):
return getattr(self, '_' + paramname.replace('Color', 'Colour'))
elif Field.valid_params.has_key(paramname):
return self._ctrl_constraints._GetParameter(paramname)
"""
dbg(suspend=1)
- dbg('wxMaskedEditMixin::_configure("%s")' % mask, indent=1)
+ dbg('MaskedEditMixin::_configure("%s")' % mask, indent=1)
# Preprocess specified mask to expand {n} syntax, handle escaped
# mask characters, etc and build the resulting positionally keyed
It will also set/reset the font if necessary and apply
formatting to the control at this time.
"""
- dbg('wxMaskedEditMixin::_SetInitialValue("%s")' % value, indent=1)
+ dbg('MaskedEditMixin::_SetInitialValue("%s")' % value, indent=1)
if not value:
self._prevValue = self._curValue = self._template
# don't apply external validation rules in this case, as template may
def _calcSize(self, size=None):
""" Calculate automatic size if allowed; must be called after the base control is instantiated"""
-## dbg('wxMaskedEditMixin::_calcSize', indent=1)
+## dbg('MaskedEditMixin::_calcSize', indent=1)
cont = (size is None or size == wx.DefaultSize)
if cont and self._autofit:
def _setFont(self):
""" Set the control's font typeface -- pass the font name as str."""
-## dbg('wxMaskedEditMixin::_setFont', indent=1)
+## dbg('MaskedEditMixin::_setFont', indent=1)
if not self._useFixedWidthFont:
self._font = wx.SystemSettings_GetFont(wx.SYS_DEFAULT_GUI_FONT)
else:
EVT_TEXT events for the same change.)
"""
newvalue = self._GetValue()
- dbg('wxMaskedEditMixin::_OnTextChange: value: "%s"' % newvalue, indent=1)
+ dbg('MaskedEditMixin::_OnTextChange: value: "%s"' % newvalue, indent=1)
bValid = False
if self._ignoreChange: # ie. if an "intermediate text change event"
dbg(indent=0)
if key in self._nav and event.ControlDown():
# then this is the only place we will likely see these events;
# process them now:
- dbg('wxMaskedEditMixin::OnKeyDown: calling _OnChar')
+ dbg('MaskedEditMixin::OnKeyDown: calling _OnChar')
self._OnChar(event)
return
# else allow regular EVT_CHAR key processing
This is the engine of wxMaskedEdit controls. It examines each keystroke,
decides if it's allowed, where it should go or what action to take.
"""
- dbg('wxMaskedEditMixin::_OnChar', indent=1)
+ dbg('MaskedEditMixin::_OnChar', indent=1)
# Get keypress value, adjusted by control options (e.g. convert to upper etc)
key = event.GetKeyCode()
10, 14
etc.
"""
- dbg('wxMaskedEditMixin::_FindFieldExtent(pos=%s, getslice=%s)' % (
+ dbg('MaskedEditMixin::_FindFieldExtent(pos=%s, getslice=%s)' % (
str(pos), str(getslice)) ,indent=1)
field = self._FindField(pos)
when calculating the current field.
"""
-## dbg('wxMaskedEditMixin::_FindField(pos=%s)' % str(pos) ,indent=1)
+## dbg('MaskedEditMixin::_FindField(pos=%s)' % str(pos) ,indent=1)
if pos is None: pos = self._GetInsertionPoint()
elif pos < 0 or pos > self._masklength:
raise IndexError('position %s out of range of control' % str(pos))
def ClearValue(self):
""" Blanks the current control value by replacing it with the default value."""
- dbg("wxMaskedEditMixin::ClearValue - value reset to default value (template)")
+ dbg("MaskedEditMixin::ClearValue - value reset to default value (template)")
self._SetValue( self._template )
self._SetInsertionPoint(0)
self.Refresh()
Makes up-arrow act like shift-tab should; ie. take you to start of
previous field.
"""
- dbg('wxMaskedEditMixin::_OnUpNumeric', indent=1)
+ dbg('MaskedEditMixin::_OnUpNumeric', indent=1)
event.m_shiftDown = 1
dbg('event.ShiftDown()?', event.ShiftDown())
self._OnChangeField(event)
Used in response to left/right navigation keys; makes these actions skip
over mask template chars.
"""
- dbg("wxMaskedEditMixin::_OnArrow", indent=1)
+ dbg("MaskedEditMixin::_OnArrow", indent=1)
pos = self._GetInsertionPoint()
keycode = event.GetKeyCode()
sel_start, sel_to = self._GetSelection()
def _OnCtrl_S(self, event):
""" Default Ctrl-S handler; prints value information if demo enabled. """
- dbg("wxMaskedEditMixin::_OnCtrl_S")
+ dbg("MaskedEditMixin::_OnCtrl_S")
if self._demo:
- print 'wxMaskedEditMixin.GetValue() = "%s"\nwxMaskedEditMixin.GetPlainValue() = "%s"' % (self.GetValue(), self.GetPlainValue())
+ print 'MaskedEditMixin.GetValue() = "%s"\nMaskedEditMixin.GetPlainValue() = "%s"' % (self.GetValue(), self.GetPlainValue())
print "Valid? => " + str(self.IsValid())
print "Current field, start, end, value =", str( self._FindFieldExtent(getslice=True))
return False
def _OnCtrl_X(self, event=None):
""" Handles ctrl-x keypress in control and Cut operation on context menu.
Should return False to skip other processing. """
- dbg("wxMaskedEditMixin::_OnCtrl_X", indent=1)
+ dbg("MaskedEditMixin::_OnCtrl_X", indent=1)
self.Cut()
dbg(indent=0)
return False
def _OnCtrl_V(self, event=None):
""" Handles ctrl-V keypress in control and Paste operation on context menu.
Should return False to skip other processing. """
- dbg("wxMaskedEditMixin::_OnCtrl_V", indent=1)
+ dbg("MaskedEditMixin::_OnCtrl_V", indent=1)
self.Paste()
dbg(indent=0)
return False
def _OnCtrl_Z(self, event=None):
""" Handles ctrl-Z keypress in control and Undo operation on context menu.
Should return False to skip other processing. """
- dbg("wxMaskedEditMixin::_OnCtrl_Z", indent=1)
+ dbg("MaskedEditMixin::_OnCtrl_Z", indent=1)
self.Undo()
dbg(indent=0)
return False
def _OnErase(self, event=None):
""" Handles backspace and delete keypress in control. Should return False to skip other processing."""
- dbg("wxMaskedEditMixin::_OnErase", indent=1)
+ dbg("MaskedEditMixin::_OnErase", indent=1)
sel_start, sel_to = self._GetSelection() ## check for a range of selected text
if event is None: # called as action routine from Cut() operation.
def _OnEnd(self,event):
""" Handles End keypress in control. Should return False to skip other processing. """
- dbg("wxMaskedEditMixin::_OnEnd", indent=1)
+ dbg("MaskedEditMixin::_OnEnd", indent=1)
pos = self._adjustPos(self._GetInsertionPoint(), event.GetKeyCode())
if not event.ControlDown():
end = self._masklength # go to end of control
Changes the event to look like a tab event, so we can then call
event.Skip() on it, and have the parent form "do the right thing."
"""
- dbg('wxMaskedEditMixin::OnReturn')
+ dbg('MaskedEditMixin::OnReturn')
event.m_keyCode = wx.WXK_TAB
event.Skip()
def _OnHome(self,event):
""" Handles Home keypress in control. Should return False to skip other processing."""
- dbg("wxMaskedEditMixin::_OnHome", indent=1)
+ dbg("MaskedEditMixin::_OnHome", indent=1)
pos = self._adjustPos(self._GetInsertionPoint(), event.GetKeyCode())
sel_start, sel_to = self._GetSelection()
control-shift-TAB, these events are not sent to the controls
by the framework.
"""
- dbg('wxMaskedEditMixin::_OnChangeField', indent = 1)
+ dbg('MaskedEditMixin::_OnChangeField', indent = 1)
# determine end of current field:
pos = self._GetInsertionPoint()
dbg('current pos:', pos)
# NOTE: doesn't yet work with SHIFT-tab under wx; the control
# never sees this event! (But I've coded for it should it ever work,
- # and it *does* work for '.' in wxIpAddrCtrl.)
+ # and it *does* work for '.' in IpAddrCtrl.)
field = self._FindField(pos)
index = field._index
field_start = field._extent[0]
def _OnDecimalPoint(self, event):
- dbg('wxMaskedEditMixin::_OnDecimalPoint', indent=1)
+ dbg('MaskedEditMixin::_OnDecimalPoint', indent=1)
pos = self._adjustPos(self._GetInsertionPoint(), event.GetKeyCode())
def _OnChangeSign(self, event):
- dbg('wxMaskedEditMixin::_OnChangeSign', indent=1)
+ dbg('MaskedEditMixin::_OnChangeSign', indent=1)
key = event.GetKeyCode()
pos = self._adjustPos(self._GetInsertionPoint(), key)
value = self._eraseSelection()
This handler is only registered if the mask is a numeric mask.
It allows the insertion of ',' or '.' if appropriate.
"""
- dbg('wxMaskedEditMixin::_OnGroupChar', indent=1)
+ dbg('MaskedEditMixin::_OnGroupChar', indent=1)
keep_processing = True
pos = self._adjustPos(self._GetInsertionPoint(), event.GetKeyCode())
sel_start, sel_to = self._GetSelection()
def _OnAutoCompleteField(self, event):
- dbg('wxMaskedEditMixin::_OnAutoCompleteField', indent =1)
+ dbg('MaskedEditMixin::_OnAutoCompleteField', indent =1)
pos = self._GetInsertionPoint()
field = self._FindField(pos)
edit_start, edit_end, slice = self._FindFieldExtent(pos, getslice=True)
Function called if autoselect feature is enabled and entire control
is selected:
"""
- dbg('wxMaskedEditMixin::OnAutoSelect', field._index)
+ dbg('MaskedEditMixin::OnAutoSelect', field._index)
if match_index is not None:
field._autoCompleteIndex = match_index
"""
'Fixes' an floating point control. Collapses spaces, right-justifies, etc.
"""
- dbg('wxMaskedEditMixin::_adjustFloat, candidate = "%s"' % candidate, indent=1)
+ dbg('MaskedEditMixin::_adjustFloat, candidate = "%s"' % candidate, indent=1)
lenInt,lenFraction = [len(s) for s in self._mask.split('.')] ## Get integer, fraction lengths
if candidate is None: value = self._GetValue()
def _adjustInt(self, candidate=None):
""" 'Fixes' an integer control. Collapses spaces, right or left-justifies."""
- dbg("wxMaskedEditMixin::_adjustInt", candidate)
+ dbg("MaskedEditMixin::_adjustInt", candidate)
lenInt = self._masklength
if candidate is None: value = self._GetValue()
else: value = candidate
'Fixes' a date control, expanding the year if it can.
Applies various self-formatting options.
"""
- dbg("wxMaskedEditMixin::_adjustDate", indent=1)
+ dbg("MaskedEditMixin::_adjustDate", indent=1)
if candidate is None: text = self._GetValue()
else: text = candidate
dbg('text=', text)
def _goEnd(self, getPosOnly=False):
""" Moves the insertion point to the end of user-entry """
- dbg("wxMaskedEditMixin::_goEnd; getPosOnly:", getPosOnly, indent=1)
+ dbg("MaskedEditMixin::_goEnd; getPosOnly:", getPosOnly, indent=1)
text = self._GetValue()
## dbg('text: "%s"' % text)
i = 0
def _goHome(self, getPosOnly=False):
""" Moves the insertion point to the beginning of user-entry """
- dbg("wxMaskedEditMixin::_goHome; getPosOnly:", getPosOnly, indent=1)
+ dbg("MaskedEditMixin::_goHome; getPosOnly:", getPosOnly, indent=1)
text = self._GetValue()
for i in range(self._masklength):
if self._isMaskChar(i):
value has been changed or set programatically.
"""
dbg(suspend=1)
- dbg('wxMaskedEditMixin::_applyFormatting', indent=1)
+ dbg('MaskedEditMixin::_applyFormatting', indent=1)
# Handle negative numbers
if self._signOk:
def _getAbsValue(self, candidate=None):
""" Return an unsigned value (i.e. strip the '-' prefix if any), and sign position(s).
"""
- dbg('wxMaskedEditMixin::_getAbsValue; candidate="%s"' % candidate, indent=1)
+ dbg('MaskedEditMixin::_getAbsValue; candidate="%s"' % candidate, indent=1)
if candidate is None: text = self._GetValue()
else: text = candidate
right_signpos = text.find(')')
""" Return a signed value by adding a "-" prefix if the value
is set to negative, or a space if positive.
"""
- dbg('wxMaskedEditMixin::_getSignedValue; candidate="%s"' % candidate, indent=1)
+ dbg('MaskedEditMixin::_getSignedValue; candidate="%s"' % candidate, indent=1)
if candidate is None: text = self._GetValue()
else: text = candidate
def GetPlainValue(self, candidate=None):
""" Returns control's value stripped of the template text.
- plainvalue = wxMaskedEditMixin.GetPlainValue()
+ plainvalue = MaskedEditMixin.GetPlainValue()
"""
- dbg('wxMaskedEditMixin::GetPlainValue; candidate="%s"' % candidate, indent=1)
+ dbg('MaskedEditMixin::GetPlainValue; candidate="%s"' % candidate, indent=1)
if candidate is None: text = self._GetValue()
else: text = candidate
def IsValid(self, value=None):
""" Indicates whether the value specified (or the current value of the control
if not specified) is considered valid."""
-## dbg('wxMaskedEditMixin::IsValid("%s")' % value, indent=1)
+## dbg('MaskedEditMixin::IsValid("%s")' % value, indent=1)
if value is None: value = self._GetValue()
ret = self._CheckValid(value)
## dbg(indent=0)
def _eraseSelection(self, value=None, sel_start=None, sel_to=None):
""" Used to blank the selection when inserting a new character. """
- dbg("wxMaskedEditMixin::_eraseSelection", indent=1)
+ dbg("MaskedEditMixin::_eraseSelection", indent=1)
if value is None: value = self._GetValue()
if sel_start is None or sel_to is None:
sel_start, sel_to = self._GetSelection() ## check for a range of selected text
def _insertKey(self, char, pos, sel_start, sel_to, value, allowAutoSelect=False):
""" Handles replacement of the character at the current insertion point."""
- dbg('wxMaskedEditMixin::_insertKey', "\'" + char + "\'", pos, sel_start, sel_to, '"%s"' % value, indent=1)
+ dbg('MaskedEditMixin::_insertKey', "\'" + char + "\'", pos, sel_start, sel_to, '"%s"' % value, indent=1)
text = self._eraseSelection(value)
field = self._FindField(pos)
preserve the correct selection when the focus event is not due to tab,
we need to pull the following trick:
"""
- dbg('wxMaskedEditMixin::_OnFocus')
+ dbg('MaskedEditMixin::_OnFocus')
wx.CallAfter(self._fixSelection)
event.Skip()
self.Refresh()
effect of coloring the control appropriately.
"""
dbg(suspend=1)
- dbg('wxMaskedEditMixin::_CheckValid: candidate="%s"' % candidate, indent=1)
+ dbg('MaskedEditMixin::_CheckValid: candidate="%s"' % candidate, indent=1)
oldValid = self._valid
if candidate is None: value = self._GetValue()
else: value = candidate
""" Validate the current date value using the provided Regex filter.
Generally used for character types.BufferType
"""
- dbg('wxMaskedEditMixin::_validateDate', indent=1)
+ dbg('MaskedEditMixin::_validateDate', indent=1)
if candidate is None: value = self._GetValue()
else: value = candidate
dbg('value = "%s"' % value)
""" Validate the current time value using the provided Regex filter.
Generally used for character types.BufferType
"""
- dbg('wxMaskedEditMixin::_validateTime', indent=1)
+ dbg('MaskedEditMixin::_validateTime', indent=1)
# wxDateTime doesn't take kindly to leading/trailing spaces when parsing,
# so we eliminate them here:
if candidate is None: value = self._GetValue().strip()
def _OnKillFocus(self,event):
""" Handler for EVT_KILL_FOCUS event.
"""
- dbg('wxMaskedEditMixin::_OnKillFocus', 'isDate=',self._isDate, indent=1)
+ dbg('MaskedEditMixin::_OnKillFocus', 'isDate=',self._isDate, indent=1)
if self._mask and self._IsEditable():
self._AdjustField(self._GetInsertionPoint())
self._CheckValid() ## Call valid handler
we can assume the cause, change the insertion point to the start of
the control, and deselect.
"""
- dbg('wxMaskedEditMixin::_fixSelection', indent=1)
+ dbg('MaskedEditMixin::_fixSelection', indent=1)
if not self._mask or not self._IsEditable():
dbg(indent=0)
return
derived control because the mixin functions can't override a method of
a sibling class.
"""
- dbg("wxMaskedEditMixin::_Cut", indent=1)
+ dbg("MaskedEditMixin::_Cut", indent=1)
value = self._GetValue()
dbg('current value: "%s"' % value)
sel_start, sel_to = self._GetSelection() ## check for a range of selected text
template.
"""
dbg(suspend=1)
- dbg('wxMaskedEditMixin::_validatePaste("%(paste_text)s", %(sel_start)d, %(sel_to)d), raise_on_invalid? %(raise_on_invalid)d' % locals(), indent=1)
+ dbg('MaskedEditMixin::_validatePaste("%(paste_text)s", %(sel_start)d, %(sel_to)d), raise_on_invalid? %(raise_on_invalid)d' % locals(), indent=1)
select_length = sel_to - sel_start
maxlength = select_length
dbg('sel_to - sel_start:', maxlength)
derived control because the mixin functions can't override a
method of a sibling class.
"""
- dbg('wxMaskedEditMixin::_Paste (value = "%s")' % value, indent=1)
+ dbg('MaskedEditMixin::_Paste (value = "%s")' % value, indent=1)
if value is None:
paste_text = self._getClipboardContents()
else:
def _Undo(self):
""" Provides an Undo() method in base controls. """
- dbg("wxMaskedEditMixin::_Undo", indent=1)
+ dbg("MaskedEditMixin::_Undo", indent=1)
value = self._GetValue()
prev = self._prevValue
dbg('current value: "%s"' % value)
def _OnContextMenu(self, event):
- dbg('wxMaskedEditMixin::OnContextMenu()', indent=1)
+ dbg('MaskedEditMixin::OnContextMenu()', indent=1)
menu = wxMenu()
menu.Append(wxID_UNDO, "Undo", "")
menu.AppendSeparator()
## ---------- ---------- ---------- ---------- ---------- ---------- ----------
-class wxMaskedTextCtrl( wx.TextCtrl, wxMaskedEditMixin ):
+class MaskedTextCtrl( wx.TextCtrl, MaskedEditMixin ):
"""
- This is the primary derivation from wxMaskedEditMixin. It provides
+ This is the primary derivation from MaskedEditMixin. It provides
a general masked text control that can be configured with different
masks.
"""
name=name)
self.controlInitialized = True
- wxMaskedEditMixin.__init__( self, name, **kwargs )
+ MaskedEditMixin.__init__( self, name, **kwargs )
self._SetInitialValue(value)
if setupEventHandling:
def __repr__(self):
- return "<wxMaskedTextCtrl: %s>" % self.GetValue()
+ return "<MaskedTextCtrl: %s>" % self.GetValue()
def _GetSelection(self):
"""
Allow mixin to get the text selection of this control.
- REQUIRED by any class derived from wxMaskedEditMixin.
+ REQUIRED by any class derived from MaskedEditMixin.
"""
return self.GetSelection()
def _SetSelection(self, sel_start, sel_to):
"""
Allow mixin to set the text selection of this control.
- REQUIRED by any class derived from wxMaskedEditMixin.
+ REQUIRED by any class derived from MaskedEditMixin.
"""
-## dbg("wxMaskedTextCtrl::_SetSelection(%(sel_start)d, %(sel_to)d)" % locals())
+## dbg("MaskedTextCtrl::_SetSelection(%(sel_start)d, %(sel_to)d)" % locals())
return self.SetSelection( sel_start, sel_to )
def SetSelection(self, sel_start, sel_to):
"""
This is just for debugging...
"""
- dbg("wxMaskedTextCtrl::SetSelection(%(sel_start)d, %(sel_to)d)" % locals())
+ dbg("MaskedTextCtrl::SetSelection(%(sel_start)d, %(sel_to)d)" % locals())
wx.TextCtrl.SetSelection(self, sel_start, sel_to)
return self.GetInsertionPoint()
def _SetInsertionPoint(self, pos):
-## dbg("wxMaskedTextCtrl::_SetInsertionPoint(%(pos)d)" % locals())
+## dbg("MaskedTextCtrl::_SetInsertionPoint(%(pos)d)" % locals())
self.SetInsertionPoint(pos)
def SetInsertionPoint(self, pos):
"""
This is just for debugging...
"""
- dbg("wxMaskedTextCtrl::SetInsertionPoint(%(pos)d)" % locals())
+ dbg("MaskedTextCtrl::SetInsertionPoint(%(pos)d)" % locals())
wx.TextCtrl.SetInsertionPoint(self, pos)
def _GetValue(self):
"""
Allow mixin to get the raw value of the control with this function.
- REQUIRED by any class derived from wxMaskedEditMixin.
+ REQUIRED by any class derived from MaskedEditMixin.
"""
return self.GetValue()
def _SetValue(self, value):
"""
Allow mixin to set the raw value of the control with this function.
- REQUIRED by any class derived from wxMaskedEditMixin.
+ REQUIRED by any class derived from MaskedEditMixin.
"""
- dbg('wxMaskedTextCtrl::_SetValue("%(value)s")' % locals(), indent=1)
+ dbg('MaskedTextCtrl::_SetValue("%(value)s")' % locals(), indent=1)
# Record current selection and insertion point, for undo
self._prevSelection = self._GetSelection()
self._prevInsertionPoint = self._GetInsertionPoint()
masked control. NOTE: this must be done in the class derived
from the base wx control.
"""
- dbg('wxMaskedTextCtrl::SetValue = "%s"' % value, indent=1)
+ dbg('MaskedTextCtrl::SetValue = "%s"' % value, indent=1)
if not self._mask:
wx.TextCtrl.SetValue(self, value) # revert to base control behavior
def Clear(self):
""" Blanks the current control value by replacing it with the default value."""
- dbg("wxMaskedTextCtrl::Clear - value reset to default value (template)")
+ dbg("MaskedTextCtrl::Clear - value reset to default value (template)")
if self._mask:
self.ClearValue()
else:
def _Refresh(self):
"""
Allow mixin to refresh the base control with this function.
- REQUIRED by any class derived from wxMaskedEditMixin.
+ REQUIRED by any class derived from MaskedEditMixin.
"""
- dbg('wxMaskedTextCtrl::_Refresh', indent=1)
+ dbg('MaskedTextCtrl::_Refresh', indent=1)
wx.TextCtrl.Refresh(self)
dbg(indent=0)
validate the contents of the masked control as it refreshes.
NOTE: this must be done in the class derived from the base wx control.
"""
- dbg('wxMaskedTextCtrl::Refresh', indent=1)
+ dbg('MaskedTextCtrl::Refresh', indent=1)
self._CheckValid()
self._Refresh()
dbg(indent=0)
def _IsEditable(self):
"""
Allow mixin to determine if the base control is editable with this function.
- REQUIRED by any class derived from wxMaskedEditMixin.
+ REQUIRED by any class derived from MaskedEditMixin.
"""
return wx.TextCtrl.IsEditable(self)
## ---------- ---------- ---------- ---------- ---------- ---------- ----------
## Because calling SetSelection programmatically does not fire EVT_COMBOBOX
## events, we have to do it ourselves when we auto-complete.
-class wxMaskedComboBoxSelectEvent(wx.PyCommandEvent):
+class MaskedComboBoxSelectEvent(wx.PyCommandEvent):
def __init__(self, id, selection = 0, object=None):
wx.PyCommandEvent.__init__(self, wx.EVT_COMMAND_COMBOBOX_SELECTED, id)
return self.__selection
-class wxMaskedComboBox( wx.ComboBox, wxMaskedEditMixin ):
+class MaskedComboBox( wx.ComboBox, MaskedEditMixin ):
"""
This masked edit control adds the ability to use a masked input
on a combobox, and do auto-complete of such values.
if not kwargs.has_key('compareNoCase'):
kwargs['compareNoCase'] = True
- wxMaskedEditMixin.__init__( self, name, **kwargs )
+ MaskedEditMixin.__init__( self, name, **kwargs )
self._choices = self._ctrl_constraints._choices
dbg('self._choices:', self._choices)
def __repr__(self):
- return "<wxMaskedComboBox: %s>" % self.GetValue()
+ return "<MaskedComboBox: %s>" % self.GetValue()
def _CalcSize(self, size=None):
def _GetSelection(self):
"""
Allow mixin to get the text selection of this control.
- REQUIRED by any class derived from wxMaskedEditMixin.
+ REQUIRED by any class derived from MaskedEditMixin.
"""
return self.GetMark()
def _SetSelection(self, sel_start, sel_to):
"""
Allow mixin to set the text selection of this control.
- REQUIRED by any class derived from wxMaskedEditMixin.
+ REQUIRED by any class derived from MaskedEditMixin.
"""
return self.SetMark( sel_start, sel_to )
def _GetValue(self):
"""
Allow mixin to get the raw value of the control with this function.
- REQUIRED by any class derived from wxMaskedEditMixin.
+ REQUIRED by any class derived from MaskedEditMixin.
"""
return self.GetValue()
def _SetValue(self, value):
"""
Allow mixin to set the raw value of the control with this function.
- REQUIRED by any class derived from wxMaskedEditMixin.
+ REQUIRED by any class derived from MaskedEditMixin.
"""
# For wxComboBox, ensure that values are properly padded so that
# if varying length choices are supplied, they always show up
def _Refresh(self):
"""
Allow mixin to refresh the base control with this function.
- REQUIRED by any class derived from wxMaskedEditMixin.
+ REQUIRED by any class derived from MaskedEditMixin.
"""
wx.ComboBox.Refresh(self)
def _IsEditable(self):
"""
Allow mixin to determine if the base control is editable with this function.
- REQUIRED by any class derived from wxMaskedEditMixin.
+ REQUIRED by any class derived from MaskedEditMixin.
"""
return not self.__readonly
Override mixin's default SetCtrlParameters to detect changes in choice list, so
we can update the base control:
"""
- wxMaskedEditMixin.SetCtrlParameters(self, **kwargs )
+ MaskedEditMixin.SetCtrlParameters(self, **kwargs )
if( self.controlInitialized
and (kwargs.has_key('choices') or self._choices != self._ctrl_constraints._choices) ):
wx.ComboBox.Clear(self)
events.
"""
dbg(suspend=1) # turn off debugging around this function
- dbg('wxMaskedComboBox::GetMark', indent=1)
+ dbg('MaskedComboBox::GetMark', indent=1)
if self.__readonly:
dbg(indent=0)
return 0, 0 # no selection possible for editing
Necessary for bookkeeping on choice selection, to keep current value
current.
"""
- dbg('wxMaskedComboBox::SetSelection(%d)' % index)
+ dbg('MaskedComboBox::SetSelection(%d)' % index)
if self._mask:
self._prevValue = self._curValue
self._curValue = self._choices[index]
on the text of the control somehow interferes with the combobox's
selection mechanism for the arrow keys.
"""
- dbg('wxMaskedComboBox::OnSelectChoice', indent=1)
+ dbg('MaskedComboBox::OnSelectChoice', indent=1)
if not self._mask:
event.Skip()
Override mixin (empty) autocomplete handler, so that autocompletion causes
combobox to update appropriately.
"""
- dbg('wxMaskedComboBox::OnAutoSelect', field._index, indent=1)
+ dbg('MaskedComboBox::OnAutoSelect', field._index, indent=1)
## field._autoCompleteIndex = match_index
if field == self._ctrl_constraints:
self.SetSelection(match_index)
dbg('issuing combo selection event')
self.GetEventHandler().ProcessEvent(
- wxMaskedComboBoxSelectEvent( self.GetId(), match_index, self ) )
+ MaskedComboBoxSelectEvent( self.GetId(), match_index, self ) )
self._CheckValid()
dbg('field._autoCompleteIndex:', match_index)
dbg('self.GetSelection():', self.GetSelection())
programmatic wxComboBox.SetSelection() call to pick the appropriate
item in the list. (and then do the usual OnReturn bit.)
"""
- dbg('wxMaskedComboBox::OnReturn', indent=1)
+ dbg('MaskedComboBox::OnReturn', indent=1)
dbg('current value: "%s"' % self.GetValue(), 'current index:', self.GetSelection())
if self.GetSelection() == -1 and self.GetValue().lower().strip() in self._ctrl_constraints._compareChoices:
wx.CallAfter(self.SetSelection, self._ctrl_constraints._autoCompleteIndex)
## ---------- ---------- ---------- ---------- ---------- ---------- ----------
-class wxIpAddrCtrl( wxMaskedTextCtrl ):
+class IpAddrCtrl( MaskedTextCtrl ):
"""
- This class is a particular type of wxMaskedTextCtrl that accepts
+ This class is a particular type of MaskedTextCtrl that accepts
and understands the semantics of IP addresses, reformats input
as you move from field to field, and accepts '.' as a navigation
character, so that typing an IP address can be done naturally.
size = wx.DefaultSize,
style = wx.TE_PROCESS_TAB,
validator = wx.DefaultValidator,
- name = 'wxIpAddrCtrl',
+ name = 'IpAddrCtrl',
setupEventHandling = True, ## setup event handling by default
**kwargs):
kwargs['validRegex'] = "( \d| \d\d|(1\d\d|2[0-4]\d|25[0-5]))(\.( \d| \d\d|(1\d\d|2[0-4]\d|25[0-5]))){3}"
- wxMaskedTextCtrl.__init__(
+ MaskedTextCtrl.__init__(
self, parent, id=id, value = value,
pos=pos, size=size,
style = style,
def OnDot(self, event):
- dbg('wxIpAddrCtrl::OnDot', indent=1)
+ dbg('IpAddrCtrl::OnDot', indent=1)
pos = self._adjustPos(self._GetInsertionPoint(), event.GetKeyCode())
oldvalue = self.GetValue()
edit_start, edit_end, slice = self._FindFieldExtent(pos, getslice=True)
def GetAddress(self):
- value = wxMaskedTextCtrl.GetValue(self)
+ value = MaskedTextCtrl.GetValue(self)
return value.replace(' ','') # remove spaces from the value
def _OnCtrl_S(self, event):
- dbg("wxIpAddrCtrl::_OnCtrl_S")
+ dbg("IpAddrCtrl::_OnCtrl_S")
if self._demo:
print "value:", self.GetAddress()
return False
def SetValue(self, value):
- dbg('wxIpAddrCtrl::SetValue(%s)' % str(value), indent=1)
+ dbg('IpAddrCtrl::SetValue(%s)' % str(value), indent=1)
if type(value) not in (types.StringType, types.UnicodeType):
dbg(indent=0)
raise ValueError('%s must be a string', str(value))
else:
dbg('parts:', parts)
value = string.join(parts, '.')
- wxMaskedTextCtrl.SetValue(self, value)
+ MaskedTextCtrl.SetValue(self, value)
dbg(indent=0)
class test(wx.PySimpleApp):
def OnInit(self):
from wx.lib.rcsizer import RowColSizer
- self.frame = wx.Frame( None, -1, "wxMaskedEditMixin 0.0.7 Demo Page #1", size = (700,600))
+ self.frame = wx.Frame( None, -1, "MaskedEditMixin 0.0.7 Demo Page #1", size = (700,600))
self.panel = wx.Panel( self.frame, -1)
self.sizer = RowColSizer()
self.labels = []
self.sizer.Add( wx.StaticText( self.panel, -1, control[4][:20]),row=rowcount, col=3,border=5, flag=wx.ALL)
if control in controls[:]:#-2]:
- newControl = wxMaskedTextCtrl( self.panel, -1, "",
+ newControl = MaskedTextCtrl( self.panel, -1, "",
mask = control[1],
excludeChars = control[2],
formatcodes = control[3],
demo = True)
if control[6]: newControl.SetCtrlParameters(choiceRequired = True)
else:
- newControl = wxMaskedComboBox( self.panel, -1, "",
+ newControl = MaskedComboBox( self.panel, -1, "",
choices = control[7],
choiceRequired = True,
mask = control[1],
("US Zip Code","USZIP"),
("US Zip+4","USZIPPLUS4"),
("Email Address","EMAIL"),
- ("IP Address", "(derived control wxIpAddrCtrl)")
+ ("IP Address", "(derived control IpAddrCtrl)")
]
for control in controls:
self.sizer.Add( wx.StaticText( self.panel, -1, control[0]),row=rowcount, col=0,border=5,flag=wx.ALL)
self.sizer.Add( wx.StaticText( self.panel, -1, control[1]),row=rowcount, col=1,border=5, flag=wx.ALL)
if control in controls[:-1]:
- self.sizer.Add( wxMaskedTextCtrl( self.panel, -1, "",
+ self.sizer.Add( MaskedTextCtrl( self.panel, -1, "",
autoformat = control[1],
demo = True),
row=rowcount,col=2,flag=wx.ALL,border=5)
else:
- self.sizer.Add( wxIpAddrCtrl( self.panel, -1, "", demo=True ),
+ self.sizer.Add( IpAddrCtrl( self.panel, -1, "", demo=True ),
row=rowcount,col=2,flag=wx.ALL,border=5)
rowcount += 1
## control in the EVT_TEXT handler, and if *different*, call event.Skip()
## to propagate it down the event chain, and let the application see it.
##
-## 2. WS: wxMaskedComboBox is deficient in several areas, all having to do with the
+## 2. WS: MaskedComboBox is deficient in several areas, all having to do with the
## behavior of the underlying control that I can't fix. The problems are:
## a) The background coloring doesn't work in the text field of the control;
## instead, there's a only border around it that assumes the correct color.
## b) The control will not pass WXK_TAB to the event handler, no matter what
## I do, and there's no style wxCB_PROCESS_TAB like wxTE_PROCESS_TAB to
-## indicate that we want these events. As a result, wxMaskedComboBox
-## doesn't do the nice field-tabbing that wxMaskedTextCtrl does.
+## indicate that we want these events. As a result, MaskedComboBox
+## doesn't do the nice field-tabbing that MaskedTextCtrl does.
## c) Auto-complete had to be reimplemented for the control because programmatic
## setting of the value of the text field does not set up the auto complete
## the way that the control processing keystrokes does. (But I think I've
## implemented has its flaws, not the least of which is that due to the
## strategy that I'm using, the paste buffer is always replaced by the
## contents of the control's selection when in focus, on each keystroke;
-## this makes it impossible to paste anything into a wxMaskedComboBox
+## this makes it impossible to paste anything into a MaskedComboBox
## at the moment... :-(
## e) The other deficient behavior, likely induced by the workaround for (d),
## is that you can can't shift-left to select more than one character
## 3. WS: Controls on wxPanels don't seem to pass Shift-WXK_TAB to their
## EVT_KEY_DOWN or EVT_CHAR event handlers. Until this is fixed in
## wxWindows, shift-tab won't take you backwards through the fields of
-## a wxMaskedTextCtrl like it should. Until then Shifted arrow keys will
+## a MaskedTextCtrl like it should. Until then Shifted arrow keys will
## work like shift-tab and tab ought to.
##
## fields. Example: City validates against list of cities, or zip vs zip code list.
## 2. Allow optional monetary symbols (eg. $, pounds, etc.) at front of a "decimal"
## control.
-## 3. Fix shift-left selection for wxMaskedComboBox.
+## 3. Fix shift-left selection for MaskedComboBox.
## 5. Transform notion of "decimal control" to be less "entire control"-centric,
## so that monetary symbols can be included and still have the appropriate
## semantics. (Big job, as currently written, but would make control even
## (Reported) bugs fixed:
## 1. Right-click menu allowed "cut" operation that destroyed mask
## (was implemented by base control)
-## 2. wxMaskedComboBox didn't allow .Append() of mixed-case values; all
+## 2. MaskedComboBox didn't allow .Append() of mixed-case values; all
## got converted to lower case.
-## 3. wxMaskedComboBox selection didn't deal with spaces in values
+## 3. MaskedComboBox selection didn't deal with spaces in values
## properly when autocompleting, and didn't have a concept of "next"
## match for handling choice list duplicates.
-## 4. Size of wxMaskedComboBox was always default.
+## 4. Size of MaskedComboBox was always default.
## 5. Email address regexp allowed some "non-standard" things, and wasn't
## general enough.
-## 6. Couldn't easily reset wxMaskedComboBox contents programmatically.
+## 6. Couldn't easily reset MaskedComboBox contents programmatically.
## 7. Couldn't set emptyInvalid during construction.
## 8. Under some versions of wxPython, readonly comboboxes can apparently
## return a GetInsertionPoint() result (655535), causing masked control
## 13. Fixed a couple of coding bugs being flagged by Python2.1.
## 14. Fixed several issues with sign positioning, erasure and validity
## checking for "numeric" masked controls.
-## 15. Added validation to wxIpAddrCtrl.SetValue().
+## 15. Added validation to IpAddrCtrl.SetValue().
##
## Version 1.1
## 1. Changed calling interface to use boolean "useFixedWidthFont" (True by default)
## fixed failure to obey case conversion codes when pasting.
## 11. Implemented '0' (zero-pad) formatting code, as it wasn't being done anywhere...
## 12. Removed condition from OnDecimalPoint, so that it always truncates right on '.'
-## 13. Enhanced wxIpAddrCtrl to use right-insert fields, selection on field traversal,
+## 13. Enhanced IpAddrCtrl to use right-insert fields, selection on field traversal,
## individual field validation to prevent field values > 255, and require explicit
## tab/. to change fields.
## 14. Added handler for left double-click to select field under cursor.
## attribute, for more consistent and controllable coloring.
## 17. Added retainFieldValidation parameter, allowing top-level constraints
## such as "validRequired" to be set independently of field-level equivalent.
-## (needed in wxTimeCtrl for bounds constraints.)
+## (needed in TimeCtrl for bounds constraints.)
## 18. Refactored code a bit, cleaned up and commented code more heavily, fixed
## some of the logic for setting/resetting parameters, eg. fillChar, defaultValue,
## etc.
## than making assumptions about character width.
## 7. Fixed GetMaskParameter(), which was non-functional in previous version.
## 8. Fixed exceptions raised to provide info on which control had the error.
-## 9. Fixed bug in choice management of wxMaskedComboBox.
-## 10. Fixed bug in wxIpAddrCtrl causing traceback if field value was of
-## the form '# #'. Modified control code for wxIpAddrCtrl so that '.'
+## 9. Fixed bug in choice management of MaskedComboBox.
+## 10. Fixed bug in IpAddrCtrl causing traceback if field value was of
+## the form '# #'. Modified control code for IpAddrCtrl so that '.'
## in the middle of a field clips the rest of that field, similar to
## decimal and integer controls.
##
## is not desired in every position. Added IsDefault() function to mean "does the value
## equal the template?" and modified .IsEmpty() to mean "do all of the editable
## positions in the template == the fillChar?"
-## 10. Extracted mask logic into mixin, so we can have both wxMaskedTextCtrl and wxMaskedComboBox,
+## 10. Extracted mask logic into mixin, so we can have both MaskedTextCtrl and MaskedComboBox,
## now included.
-## 11. wxMaskedComboBox now adds the capability to validate from list of valid values.
+## 11. MaskedComboBox now adds the capability to validate from list of valid values.
## Example: City validates against list of cities, or zip vs zip code list.
## 12. Fixed oversight in EVT_TEXT handler that prevented the events from being
## passed to the next handler in the event chain, causing updates to the
## control to be invisible to the parent code.
-## 13. Added IPADDR autoformat code, and subclass wxIpAddrCtrl for controlling tabbing within
+## 13. Added IPADDR autoformat code, and subclass IpAddrCtrl for controlling tabbing within
## the control, that auto-reformats as you move between cells.
## 14. Mask characters [A,a,X,#] can now appear in the format string as literals, by using '\'.
## 15. It is now possible to specify repeating masks, e.g. #{3}-#{3}-#{14}
## 19. Enhanced tabbing logic so that tab takes you to the next field if the
## control is a multi-field control.
## 20. Added stub method called whenever the control "changes fields", that
-## can be overridden by subclasses (eg. wxIpAddrCtrl.)
+## can be overridden by subclasses (eg. IpAddrCtrl.)
## 21. Changed a lot of code to be more functionally-oriented so side-effects
## aren't as problematic when maintaining code and/or adding features.
## Eg: IsValid() now does not have side-effects; it merely reflects the
## 4. Home and End keys now supported to move cursor to beginning or end of field.
## 5. Un-signed integers and decimals now supported.
## 6. Cosmetic improvements to the demo.
-## 7. Class renamed to wxMaskedTextCtrl.
+## 7. Class renamed to MaskedTextCtrl.
## 8. Can now specify include characters that will override the basic
## controls: for example, includeChars = "@." for email addresses
## 9. Added mask character 'C' -> allow any upper or lowercase character
# NOTE:
# This was written to provide a numeric edit control for wxPython that
# does things like right-insert (like a calculator), and does grouping, etc.
-# (ie. the features of wxMaskedTextCtrl), but allows Get/Set of numeric
+# (ie. the features of MaskedTextCtrl), but allows Get/Set of numeric
# values, rather than text.
#
-# wxMaskedNumCtrl permits integer, and floating point values to be set
+# MaskedNumCtrl permits integer, and floating point values to be set
# retrieved or set via .GetValue() and .SetValue() (type chosen based on
# fraction width, and provides an EVT_MASKEDNUM() event function for trapping
# changes to the control.
# Similarly, replacing the contents of the control with '-' will result in
# a selected (absolute) value of -1.
#
-# wxMaskedNumCtrl also supports range limits, with the option of either
+# MaskedNumCtrl also supports range limits, with the option of either
# enforcing them or simply coloring the text of the control if the limits
# are exceeded.
#
-# wxMaskedNumCtrl is intended to support fixed-point numeric entry, and
-# is derived from wxMaskedTextCtrl. As such, it supports a limited range
+# MaskedNumCtrl is intended to support fixed-point numeric entry, and
+# is derived from MaskedTextCtrl. As such, it supports a limited range
# of values to comply with a fixed-width entry mask.
#----------------------------------------------------------------------------
# 12/09/2003 - Jeff Grimmett (grimmtooth@softhome.net)
#
# o Updated for wx namespace
#
+# 12/20/2003 - Jeff Grimmett (grimmtooth@softhome.net)
+#
+# o wxMaskedEditMixin -> MaskedEditMixin
+# o wxMaskedTextCtrl -> MaskedTextCtrl
+# o wxMaskedNumNumberUpdatedEvent -> MaskedNumNumberUpdatedEvent
+# o wxMaskedNumCtrl -> MaskedNumCtrl
+#
"""<html><body>
<P>
-<B>wxMaskedNumCtrl:</B>
+<B>MaskedNumCtrl:</B>
<UL>
<LI>allows you to get and set integer or floating point numbers as value,</LI>
<LI>provides bounds support and optional value limiting,</LI>
-<LI>has the right-insert input style that wxMaskedTextCtrl supports,</LI>
+<LI>has the right-insert input style that MaskedTextCtrl supports,</LI>
<LI>provides optional automatic grouping, sign control and format, grouping and decimal
character selection, etc. etc.</LI>
</UL>
<P>
-Being derived from wxMaskedTextCtrl, the control only allows
+Being derived from MaskedTextCtrl, the control only allows
fixed-point notation. That is, it has a fixed (though reconfigurable)
maximum width for the integer portion and optional fixed width
fractional portion.
<P>
Here's the API:
<DL><PRE>
- <B>wxMaskedNumCtrl</B>(
+ <B>MaskedNumCtrl</B>(
parent, id = -1,
<B>value</B> = 0,
pos = wxDefaultPosition,
MININT = -maxint-1
from wx.tools.dbg import Logger
-from wx.lib.maskededit import wxMaskedEditMixin, wxMaskedTextCtrl, Field
+from wx.lib.maskededit import MaskedEditMixin, MaskedTextCtrl, Field
dbg = Logger()
dbg(enable=0)
#----------------------------------------------------------------------------
-class wxMaskedNumNumberUpdatedEvent(wx.PyCommandEvent):
+class MaskedNumNumberUpdatedEvent(wx.PyCommandEvent):
def __init__(self, id, value = 0, object=None):
wx.PyCommandEvent.__init__(self, wxEVT_COMMAND_MASKED_NUMBER_UPDATED, id)
#----------------------------------------------------------------------------
-class wxMaskedNumCtrl(wxMaskedTextCtrl):
+class MaskedNumCtrl(MaskedTextCtrl):
valid_ctrl_params = {
'integerWidth': 10, # by default allow all 32-bit integers
name = "maskednum",
**kwargs ):
- dbg('wxMaskedNumCtrl::__init__', indent=1)
+ dbg('MaskedNumCtrl::__init__', indent=1)
# Set defaults for control:
dbg('setting defaults:')
- for key, param_value in wxMaskedNumCtrl.valid_ctrl_params.items():
+ for key, param_value in MaskedNumCtrl.valid_ctrl_params.items():
# This is done this way to make setattr behave consistently with
# "private attribute" name mangling
setattr(self, '_' + key, copy.copy(param_value))
# Assign defaults for all attributes:
- init_args = copy.deepcopy(wxMaskedNumCtrl.valid_ctrl_params)
+ init_args = copy.deepcopy(MaskedNumCtrl.valid_ctrl_params)
dbg('kwargs:', kwargs)
for key, param_value in kwargs.items():
key = key.replace('Color', 'Colour')
- if key not in wxMaskedNumCtrl.valid_ctrl_params.keys():
+ if key not in MaskedNumCtrl.valid_ctrl_params.keys():
raise AttributeError('invalid keyword argument "%s"' % key)
else:
init_args[key] = param_value
self._typedSign = False
# Construct the base control:
- wxMaskedTextCtrl.__init__(
+ MaskedTextCtrl.__init__(
self, parent, id, '',
pos, size, style, validator, name,
mask = mask,
# Ensure proper coloring:
self.Refresh()
- dbg('finished wxMaskedNumCtrl::__init__', indent=0)
+ dbg('finished MaskedNumCtrl::__init__', indent=0)
def SetParameters(self, **kwargs):
"""
This routine is used to initialize and reconfigure the control:
"""
- dbg('wxMaskedNumCtrl::SetParameters', indent=1)
+ dbg('MaskedNumCtrl::SetParameters', indent=1)
maskededit_kwargs = {}
reset_fraction_width = False
# for all other parameters, assign keyword args as appropriate:
for key, param_value in kwargs.items():
key = key.replace('Color', 'Colour')
- if key not in wxMaskedNumCtrl.valid_ctrl_params.keys():
+ if key not in MaskedNumCtrl.valid_ctrl_params.keys():
raise AttributeError('invalid keyword argument "%s"' % key)
- elif key not in wxMaskedEditMixin.valid_ctrl_params.keys():
+ elif key not in MaskedEditMixin.valid_ctrl_params.keys():
setattr(self, '_' + key, param_value)
elif key in ('mask', 'autoformat'): # disallow explicit setting of mask
raise AttributeError('invalid keyword argument "%s"' % key)
dbg('abs(value):', value)
self._isNeg = False
- elif not self._allowNone and wxMaskedTextCtrl.GetValue(self) == '':
+ elif not self._allowNone and MaskedTextCtrl.GetValue(self) == '':
if self._min > 0:
value = self._min
else:
sel_start, sel_to = self.GetSelection()
self._SetValue(self._toGUI(value))
self.Refresh() # recolor as appropriate
- dbg('finished wxMaskedNumCtrl::SetParameters', indent=0)
+ dbg('finished MaskedNumCtrl::SetParameters', indent=0)
else:
fracstart, fracend = self._fields[1]._extent
if candidate is None:
- value = self._toGUI(wxMaskedTextCtrl.GetValue(self))
+ value = self._toGUI(MaskedTextCtrl.GetValue(self))
else:
value = self._toGUI(candidate)
fracstring = value[fracstart:fracend].strip()
return string.atof(fracstring)
def _OnChangeSign(self, event):
- dbg('wxMaskedNumCtrl::_OnChangeSign', indent=1)
+ dbg('MaskedNumCtrl::_OnChangeSign', indent=1)
self._typedSign = True
- wxMaskedEditMixin._OnChangeSign(self, event)
+ MaskedEditMixin._OnChangeSign(self, event)
dbg(indent=0)
def _disallowValue(self):
- dbg('wxMaskedNumCtrl::_disallowValue')
+ dbg('MaskedNumCtrl::_disallowValue')
# limited and -1 is out of bounds
if self._typedSign:
self._isNeg = False
by the user.
"""
- dbg('wxMaskedNumCtrl::_SetValue("%s")' % value, indent=1)
+ dbg('MaskedNumCtrl::_SetValue("%s")' % value, indent=1)
if( (self._fractionWidth and value.find(self._decimalChar) == -1) or
(self._fractionWidth == 0 and value.find(self._decimalChar) != -1) ) :
if numvalue == "":
if self._allowNone:
- dbg('calling base wxMaskedTextCtrl._SetValue(self, "%s")' % value)
- wxMaskedTextCtrl._SetValue(self, value)
+ dbg('calling base MaskedTextCtrl._SetValue(self, "%s")' % value)
+ MaskedTextCtrl._SetValue(self, value)
self.Refresh()
return
elif self._min > 0 and self.IsLimited():
# reasonable instead:
dbg('setting replacement value:', replacement)
self._SetValue(self._toGUI(replacement))
- sel_start = wxMaskedTextCtrl.GetValue(self).find(str(abs(replacement))) # find where it put the 1, so we can select it
+ sel_start = MaskedTextCtrl.GetValue(self).find(str(abs(replacement))) # find where it put the 1, so we can select it
sel_to = sel_start + len(str(abs(replacement)))
dbg('queuing selection of (%d, %d)' %(sel_start, sel_to))
wx.CallAfter(self.SetInsertionPoint, sel_start)
sel_start, sel_to = self._GetSelection() # record current insertion point
- dbg('calling base wxMaskedTextCtrl._SetValue(self, "%s")' % adjvalue)
- wxMaskedTextCtrl._SetValue(self, adjvalue)
+ dbg('calling base MaskedTextCtrl._SetValue(self, "%s")' % adjvalue)
+ MaskedTextCtrl._SetValue(self, adjvalue)
# After all actions so far scheduled, check that resulting cursor
# position is appropriate, and move if not:
wx.CallAfter(self._CheckInsertionPoint)
- dbg('finished wxMaskedNumCtrl::_SetValue', indent=0)
+ dbg('finished MaskedNumCtrl::_SetValue', indent=0)
def _CheckInsertionPoint(self):
# If current insertion point is before the end of the integer and
# its before the 1st digit, place it just after the sign position:
- dbg('wxMaskedNumCtrl::CheckInsertionPoint', indent=1)
+ dbg('MaskedNumCtrl::CheckInsertionPoint', indent=1)
sel_start, sel_to = self._GetSelection()
text = self._GetValue()
if sel_to < self._fields[0]._extent[1] and text[sel_to] in (' ', '-', '('):
grouping characters auto selects the digit before or after the
grouping character, so that the erasure does the right thing.
"""
- dbg('wxMaskedNumCtrl::_OnErase', indent=1)
+ dbg('MaskedNumCtrl::_OnErase', indent=1)
#if grouping digits, make sure deletes next to group char always
# delete next digit to appropriate side:
if self._groupDigits:
key = event.GetKeyCode()
- value = wxMaskedTextCtrl.GetValue(self)
+ value = MaskedTextCtrl.GetValue(self)
sel_start, sel_to = self._GetSelection()
if key == wx.WXK_BACK:
self.SetInsertionPoint(sel_start)
self.SetSelection(sel_start, sel_to+1)
- wxMaskedTextCtrl._OnErase(self, event)
+ MaskedTextCtrl._OnErase(self, event)
dbg(indent=0)
text events. So we check for actual changes to the text
before passing the events on.
"""
- dbg('wxMaskedNumCtrl::OnTextChange', indent=1)
- if not wxMaskedTextCtrl._OnTextChange(self, event):
+ dbg('MaskedNumCtrl::OnTextChange', indent=1)
+ if not MaskedTextCtrl._OnTextChange(self, event):
dbg(indent=0)
return
if value != self._oldvalue:
try:
self.GetEventHandler().ProcessEvent(
- wxMaskedNumNumberUpdatedEvent( self.GetId(), self.GetValue(), self ) )
+ MaskedNumNumberUpdatedEvent( self.GetId(), self.GetValue(), self ) )
except ValueError:
dbg(indent=0)
return
def _GetValue(self):
"""
- Override of wxMaskedTextCtrl to allow amixin to get the raw text value of the
+ Override of MaskedTextCtrl to allow amixin to get the raw text value of the
control with this function.
"""
return wx.TextCtrl.GetValue(self)
"""
Returns the current numeric value of the control.
"""
- return self._fromGUI( wxMaskedTextCtrl.GetValue(self) )
+ return self._fromGUI( MaskedTextCtrl.GetValue(self) )
def SetValue(self, value):
"""
A ValueError exception will be raised if an invalid value
is specified.
"""
- wxMaskedTextCtrl.SetValue( self, self._toGUI(value) )
+ MaskedTextCtrl.SetValue( self, self._toGUI(value) )
def SetIntegerWidth(self, value):
If min > the max value allowed by the width of the control,
the function will return False, and the min will not be set.
"""
- dbg('wxMaskedNumCtrl::SetMin(%s)' % repr(min), indent=1)
+ dbg('MaskedNumCtrl::SetMin(%s)' % repr(min), indent=1)
if( self._max is None
or min is None
or (self._max is not None and self._max >= min) ):
type and bounds checking and raises ValueError if argument is
not a valid value.
"""
- dbg('wxMaskedNumCtrl::_toGUI(%s)' % repr(value), indent=1)
+ dbg('MaskedNumCtrl::_toGUI(%s)' % repr(value), indent=1)
if value is None and self.IsNoneAllowed():
dbg(indent=0)
return self._template
value = long(value)
except Exception, e:
dbg('exception raised:', e, indent=0)
- raise ValueError ('wxMaskedNumCtrl requires numeric value, passed %s'% repr(value) )
+ raise ValueError ('MaskedNumCtrl requires numeric value, passed %s'% repr(value) )
elif type(value) not in (types.IntType, types.LongType, types.FloatType):
dbg(indent=0)
raise ValueError (
- 'wxMaskedNumCtrl requires numeric value, passed %s'% repr(value) )
+ 'MaskedNumCtrl requires numeric value, passed %s'% repr(value) )
if not self._allowNegative and value < 0:
raise ValueError (
Conversion function used in getting the value of the control.
"""
dbg(suspend=0)
- dbg('wxMaskedNumCtrl::_fromGUI(%s)' % value, indent=1)
+ dbg('MaskedNumCtrl::_fromGUI(%s)' % value, indent=1)
# One or more of the underlying text control implementations
# issue an intermediate EVT_TEXT when replacing the control's
# value, where the intermediate value is an empty string.
Preprocessor for base control paste; if value needs to be right-justified
to fit in control, do so prior to paste:
"""
- dbg('wxMaskedNumCtrl::_Paste (value = "%s")' % value)
+ dbg('MaskedNumCtrl::_Paste (value = "%s")' % value)
if value is None:
paste_text = self._getClipboardContents()
else:
paste_text = self._toGUI(paste_text)
self._SetSelection(0, len(self._mask))
- return wxMaskedEditMixin._Paste(self,
+ return MaskedEditMixin._Paste(self,
paste_text,
raise_on_invalid=raise_on_invalid,
just_return_value=just_return_value)
style = wx.DEFAULT_DIALOG_STYLE ):
wx.Dialog.__init__(self, parent, id, title, pos, size, style)
- self.int_ctrl = wxMaskedNumCtrl(self, wx.NewId(), size=(55,20))
+ self.int_ctrl = MaskedNumCtrl(self, wx.NewId(), size=(55,20))
self.OK = wx.Button( self, wx.ID_OK, "OK")
self.Cancel = wx.Button( self, wx.ID_CANCEL, "Cancel")
return True
def OnClick(self, event):
- dlg = myDialog(self.panel, -1, "test wxMaskedNumCtrl")
+ dlg = myDialog(self.panel, -1, "test MaskedNumCtrl")
dlg.int_ctrl.SetValue(501)
dlg.int_ctrl.SetInsertionPoint(1)
dlg.int_ctrl.SetSelection(1,2)
#----------------------------------------------------------------------------
# Name: wxPython.lib.mixins.grid
-# Purpose: Helpful mix-in classes for wxGrid
+# Purpose: Helpful mix-in classes for wx.Grid
#
# Author: Robin Dunn
#
# o 2.5 compatability update.
# o Untested
#
+# 12/21/2003 - Jeff Grimmett (grimmtooth@softhome.net)
+#
+# o wxGridAutoEditMixin -> GridAutoEditMixin
+#
import wx
import wx.grid
#----------------------------------------------------------------------------
-class wxGridAutoEditMixin:
+class GridAutoEditMixin:
"""A mix-in class that automatically enables the grid edit control when
a cell is selected.
# o 2.5 compatability update.
# o ListCtrlSelectionManagerMix untested.
#
+# 12/21/2003 - Jeff Grimmett (grimmtooth@softhome.net)
+#
+# o wxColumnSorterMixin -> ColumnSorterMixin
+# o wxListCtrlAutoWidthMixin -> ListCtrlAutoWidthMixin
+#
import locale
import wx
#----------------------------------------------------------------------------
-class wxColumnSorterMixin:
+class ColumnSorterMixin:
"""
A mixin class that handles sorting of a wx.ListCtrl in REPORT mode when
the column header is clicked on.
#----------------------------------------------------------------------------
#----------------------------------------------------------------------------
-class wxListCtrlAutoWidthMixin:
+class ListCtrlAutoWidthMixin:
""" A mix-in class that automatically resizes the last column to take up
the remaining width of the wx.ListCtrl.
# Created: 2002/11/20
# Version: 0.1
# RCS-ID: $Id$
-# License: wxWindows licensie
+# License: wxWindows license
#----------------------------------------------------------------------
# 12/09/2003 - Jeff Grimmett (grimmtooth@softhome.net)
#
# o 2.5 compatability update.
#
+# 12/20/2003 - Jeff Grimmett (grimmtooth@softhome.net)
+#
+# o wxMultiSash -> MultiSash
+# o wxMultiSplit -> MultiSplit wxMultiViewLeaf
+# o wxMultiViewLeaf -> MultiViewLeaf
+#
import wx
#----------------------------------------------------------------------
-class wxMultiSash(wx.Window):
+class MultiSash(wx.Window):
def __init__(self, *_args,**_kwargs):
apply(wx.Window.__init__,(self,) + _args,_kwargs)
self._defChild = EmptyChild
- self.child = wxMultiSplit(self,self,(0,0),self.GetSize())
+ self.child = MultiSplit(self,self,(0,0),self.GetSize())
self.Bind(wx.EVT_SIZE,self.OnMultiSize)
def SetDefaultChildClass(self,childCls):
def Clear(self):
old = self.child
- self.child = wxMultiSplit(self,self,(0,0),self.GetSize())
+ self.child = MultiSplit(self,self,(0,0),self.GetSize())
old.Destroy()
self.child.OnSize(None)
exec 'import %s' % mod
self._defChild = eval(dChild)
old = self.child
- self.child = wxMultiSplit(self,self,wxPoint(0,0),self.GetSize())
+ self.child = MultiSplit(self,self,wxPoint(0,0),self.GetSize())
self.child.SetSaveData(data['child'])
old.Destroy()
self.OnMultiSize(None)
#----------------------------------------------------------------------
-class wxMultiSplit(wx.Window):
+class MultiSplit(wx.Window):
def __init__(self,multiView,parent,pos,size,view1 = None):
wx.Window.__init__(self,id = -1,parent = parent,pos = pos,size = size,
style = wx.CLIP_CHILDREN)
self.view1.Reparent(self)
self.view1.MoveXY(0,0)
else:
- self.view1 = wxMultiViewLeaf(self.multiView,self,
+ self.view1 = MultiViewLeaf(self.multiView,self,
(0,0),self.GetSize())
self.direction = None
saveData = {}
if self.view1:
saveData['view1'] = self.view1.GetSaveData()
- if isinstance(self.view1,wxMultiSplit):
+ if isinstance(self.view1,MultiSplit):
saveData['view1IsSplit'] = 1
if self.view2:
saveData['view2'] = self.view2.GetSaveData()
- if isinstance(self.view2,wxMultiSplit):
+ if isinstance(self.view2,MultiSplit):
saveData['view2IsSplit'] = 1
saveData['direction'] = self.direction
v1,v2 = self.GetPosition()
isSplit = data.get('view1IsSplit',None)
old = self.view1
if isSplit:
- self.view1 = wxMultiSplit(self.multiView,self,
+ self.view1 = MultiSplit(self.multiView,self,
(0,0),self.GetSize())
else:
- self.view1 = wxMultiViewLeaf(self.multiView,self,
+ self.view1 = MultiViewLeaf(self.multiView,self,
(0,0),self.GetSize())
self.view1.SetSaveData(v1Data)
if old:
isSplit = data.get('view2IsSplit',None)
old = self.view2
if isSplit:
- self.view2 = wxMultiSplit(self.multiView,self,
+ self.view2 = MultiSplit(self.multiView,self,
(0,0),self.GetSize())
else:
- self.view2 = wxMultiViewLeaf(self.multiView,self,
+ self.view2 = MultiViewLeaf(self.multiView,self,
(0,0),self.GetSize())
self.view2.SetSaveData(v2Data)
if old:
def AddLeaf(self,direction,caller,pos):
if self.view2:
if caller == self.view1:
- self.view1 = wxMultiSplit(self.multiView,self,
+ self.view1 = MultiSplit(self.multiView,self,
caller.GetPosition(),
caller.GetSize(),
caller)
self.view1.AddLeaf(direction,caller,pos)
else:
- self.view2 = wxMultiSplit(self.multiView,self,
+ self.view2 = MultiSplit(self.multiView,self,
caller.GetPosition(),
caller.GetSize(),
caller)
x,y = (0,pos)
w1,h1 = (w,h-pos)
w2,h2 = (w,pos)
- self.view2 = wxMultiViewLeaf(self.multiView, self, (x,y), (w1,h1))
+ self.view2 = MultiViewLeaf(self.multiView, self, (x,y), (w1,h1))
self.view1.SetSize((w2,h2))
self.view2.OnSize(None)
#----------------------------------------------------------------------
-class wxMultiViewLeaf(wx.Window):
+class MultiViewLeaf(wx.Window):
def __init__(self,multiView,parent,pos,size):
wx.Window.__init__(self,id = -1,parent = parent,pos = pos,size = size,
style = wx.CLIP_CHILDREN)
# o 2.5 compatability update.
# o I'm a little nervous about some of it though.
#
+# 12/20/2003 - Jeff Grimmett (grimmtooth@softhome.net)
+#
+# o wxTreeModel -> TreeModel
+# o wxMVCTree -> MVCTree
+# o wxMVCTreeEvent -> MVCTreeEvent
+# o wxMVCTreeNotifyEvent -> MVCTreeNotifyEvent
+#
"""
-wxMVCTree is a control which handles hierarchical data. It is constructed
+MVCTree is a control which handles hierarchical data. It is constructed
in model-view-controller architecture, so the display of that data, and
the content of the data can be changed greatly without affecting the other parts.
-wxMVCTree actually is even more configurable than MVC normally implies, because
+MVCTree actually is even more configurable than MVC normally implies, because
almost every aspect of it is pluggable:
- wxMVCTree - Overall controller, and the window that actually gets placed
+ MVCTree - Overall controller, and the window that actually gets placed
in the GUI.
Painter - Paints the control. The 'view' part of MVC.
NodePainter - Paints just the nodes
class MVCTreeNode:
"""
- Used internally by wxMVCTree to manage its data. Contains information about
+ Used internally by MVCTree to manage its data. Contains information about
screen placement, the actual data associated with it, and more. These are
the nodes passed to all the other helper parts to do their work with.
"""
class Painter:
"""
- This is the interface that wxMVCTree expects from painters. All painters should
+ This is the interface that MVCTree expects from painters. All painters should
be Painter subclasses.
"""
def __init__(self, tree):
evt.Skip()
-class wxTreeModel:
+class TreeModel:
"""
Interface for tree models
"""
raise NotImplementedError
-class BasicTreeModel(wxTreeModel):
+class BasicTreeModel(TreeModel):
"""
A very simple treemodel implementation, but flexible enough for many needs.
"""
if not self.children.has_key(parent):
self.children[parent]=[]
self.children[parent].append(child)
- wxTreeModel.AddChild(self, parent, child)
+ TreeModel.AddChild(self, parent, child)
return child
def RemoveNode(self, node):
parent = self.parents[node]
del self.parents[node]
self.children[parent].remove(node)
- wxTreeModel.RemoveNode(self, node)
+ TreeModel.RemoveNode(self, node)
def InsertChild(self, parent, child, index):
self.parents[child]=parent
if not self.children.has_key(parent):
self.children[parent]=[]
self.children[parent].insert(child, index)
- wxTreeModel.InsertChild(self, parent, child, index)
+ TreeModel.InsertChild(self, parent, child, index)
return child
def IsLeaf(self, node):
EVT_MVCTREE_DELETE_ITEM = wx.PyEventBinder(wxEVT_MVCTREE_DELETE_ITEM, 1)
EVT_MVCTREE_KEY_DOWN = wx.PyEventBinder(wxEVT_MVCTREE_KEY_DOWN, 1)
-class wxMVCTreeEvent(wx.PyCommandEvent):
+class MVCTreeEvent(wx.PyCommandEvent):
def __init__(self, type, id, node = None, nodes = None, keyEvent = None, **kwargs):
apply(wx.PyCommandEvent.__init__, (self, type, id), kwargs)
self.node = node
def getKeyEvent(self):
return self.keyEvent
-class wxMVCTreeNotifyEvent(wxMVCTreeEvent):
+class MVCTreeNotifyEvent(MVCTreeEvent):
def __init__(self, type, id, node = None, nodes = None, **kwargs):
- apply(wxMVCTreeEvent.__init__, (self, type, id, node, nodes), kwargs)
+ apply(MVCTreeEvent.__init__, (self, type, id, node, nodes), kwargs)
self.notify = wx.NotifyEvent(type, id)
def getNotifyEvent(self):
return self.notify
-class wxMVCTree(wx.ScrolledWindow):
+class MVCTree(wx.ScrolledWindow):
"""
The main mvc tree class.
"""
return self.transform
def __repr__(self):
- return "<wxMVCTree instance at %s>" % str(hex(id(self)))
+ return "<MVCTree instance at %s>" % str(hex(id(self)))
def __str__(self):
return self.__repr__()
def NodeAdded(self, parent, child):
- e = wxMVCTreeEvent(wxEVT_MVCTREE_ADD_ITEM, self.GetId(), node = child, nodes = [parent, child])
+ e = MVCTreeEvent(wxEVT_MVCTREE_ADD_ITEM, self.GetId(), node = child, nodes = [parent, child])
self.GetEventHandler().ProcessEvent(e)
self.painter.ClearBuffer()
def NodeInserted(self, parent, child, index):
- e = wxMVCTreeEvent(wxEVT_MVCTREE_ADD_ITEM, self.GetId(), node = child, nodes = [parent, child])
+ e = MVCTreeEvent(wxEVT_MVCTREE_ADD_ITEM, self.GetId(), node = child, nodes = [parent, child])
self.GetEventHandler().ProcessEvent(e)
self.painter.ClearBuffer()
def NodeRemoved(self, node):
- e = wxMVCTreeEvent(wxEVT_MVCTREE_DELETE_ITEM, self.GetId(), node = child, nodes = [parent, child])
+ e = MVCTreeEvent(wxEVT_MVCTREE_DELETE_ITEM, self.GetId(), node = child, nodes = [parent, child])
self.GetEventHandler().ProcessEvent(e)
self.painter.ClearBuffer()
def OnKeyDown(self, evt):
- e = wxMVCTreeEvent(wxEVT_MVCTREE_KEY_DOWN, self.GetId(), keyEvent = evt)
+ e = MVCTreeEvent(wxEVT_MVCTREE_KEY_DOWN, self.GetId(), keyEvent = evt)
self.GetEventHandler().ProcessEvent(e)
def SetFont(self, font):
def SetDoubleBuffered(self, bool):
"""
- By default wxMVCTree is double-buffered.
+ By default MVCTree is double-buffered.
"""
self.doubleBuffered = bool
def SetSelection(self, nodeTuple):
if type(nodeTuple) != type(()):
nodeTuple = (nodeTuple,)
- e = wxMVCTreeNotifyEvent(wxEVT_MVCTREE_SEL_CHANGING, self.GetId(), nodeTuple[0], nodes = nodeTuple)
+ e = MVCTreeNotifyEvent(wxEVT_MVCTREE_SEL_CHANGING, self.GetId(), nodeTuple[0], nodes = nodeTuple)
self.GetEventHandler().ProcessEvent(e)
if not e.notify.IsAllowed():
return
treenode = self.nodemap[node]
node.selected = False
self._selections = list(nodeTuple)
- e = wxMVCTreeEvent(wxEVT_MVCTREE_SEL_CHANGED, self.GetId(), nodeTuple[0], nodes = nodeTuple)
+ e = MVCTreeEvent(wxEVT_MVCTREE_SEL_CHANGED, self.GetId(), nodeTuple[0], nodes = nodeTuple)
self.GetEventHandler().ProcessEvent(e)
def IsMultiSelect(self):
return
for ed in self._editors:
if ed.CanEdit(node):
- e = wxMVCTreeNotifyEvent(wxEVT_MVCTREE_BEGIN_EDIT, self.GetId(), node)
+ e = MVCTreeNotifyEvent(wxEVT_MVCTREE_BEGIN_EDIT, self.GetId(), node)
self.GetEventHandler().ProcessEvent(e)
if not e.notify.IsAllowed():
return
self._currentEditor = None
def _EditEnding(self, node):
- e = wxMVCTreeNotifyEvent(wxEVT_MVCTREE_END_EDIT, self.GetId(), node)
+ e = MVCTreeNotifyEvent(wxEVT_MVCTREE_END_EDIT, self.GetId(), node)
self.GetEventHandler().ProcessEvent(e)
if not e.notify.IsAllowed():
return False
def SetExpanded(self, node, bool):
treenode = self.nodemap[node]
if bool:
- e = wxMVCTreeNotifyEvent(wxEVT_MVCTREE_ITEM_EXPANDING, self.GetId(), node)
+ e = MVCTreeNotifyEvent(wxEVT_MVCTREE_ITEM_EXPANDING, self.GetId(), node)
self.GetEventHandler().ProcessEvent(e)
if not e.notify.IsAllowed():
return
if not treenode.built:
self.LoadChildren(treenode)
else:
- e = wxMVCTreeNotifyEvent(wxEVT_MVCTREE_ITEM_COLLAPSING, self.GetId(), node)
+ e = MVCTreeNotifyEvent(wxEVT_MVCTREE_ITEM_COLLAPSING, self.GetId(), node)
self.GetEventHandler().ProcessEvent(e)
if not e.notify.IsAllowed():
return
treenode.expanded = bool
e = None
if treenode.expanded:
- e = wxMVCTreeEvent(wxEVT_MVCTREE_ITEM_EXPANDED, self.GetId(), node)
+ e = MVCTreeEvent(wxEVT_MVCTREE_ITEM_EXPANDED, self.GetId(), node)
else:
- e = wxMVCTreeEvent(wxEVT_MVCTREE_ITEM_COLLAPSED, self.GetId(), node)
+ e = MVCTreeEvent(wxEVT_MVCTREE_ITEM_COLLAPSED, self.GetId(), node)
self.GetEventHandler().ProcessEvent(e)
self.layout.Layout(self.currentRoot)
self.transform.Transform(self.currentRoot, self.offset, self.rotation)
nodeTuple = nodeOrTuple
if type(nodeOrTuple)!= type(()):
nodeTuple = (nodeOrTuple,)
- e = wxMVCTreeNotifyEvent(wxEVT_MVCTREE_SEL_CHANGING, self.GetId(), nodeTuple[0], nodes = nodeTuple)
+ e = MVCTreeNotifyEvent(wxEVT_MVCTREE_SEL_CHANGING, self.GetId(), nodeTuple[0], nodes = nodeTuple)
self.GetEventHandler().ProcessEvent(e)
if not e.notify.IsAllowed():
return
treenode = self.nodemap[node]
treenode.selected = True
changeparents.append(treenode)
- e = wxMVCTreeEvent(wxEVT_MVCTREE_SEL_CHANGED, self.GetId(), nodeTuple[0], nodes = nodeTuple)
+ e = MVCTreeEvent(wxEVT_MVCTREE_SEL_CHANGED, self.GetId(), nodeTuple[0], nodes = nodeTuple)
self.GetEventHandler().ProcessEvent(e)
dc = wx.ClientDC(self)
self.PrepareDC(dc)
treenode = self.nodemap[node]
changeparents.append(treenode)
treenode.selected = False
- e = wxMVCTreeEvent(wxEVT_MVCTREE_SEL_CHANGED, self.GetId(), node, nodes = nodeTuple)
+ e = MVCTreeEvent(wxEVT_MVCTREE_SEL_CHANGED, self.GetId(), node, nodes = nodeTuple)
self.GetEventHandler().ProcessEvent(e)
dc = wx.ClientDC(self)
self.PrepareDC(dc)
#
# o 2.5 compatability update.
#
+# 12/20/2003 - Jeff Grimmett (grimmtooth@softhome.net)
+#
+# o wxPopupDialog -> PopupDialog
+# o wxPopupControl -> PopupControl
+#
import wx
from wx.lib.buttons import GenButtonEvent
# Tried to use wxPopupWindow but the control misbehaves on MSW
-class wxPopupDialog(wx.Dialog):
+class PopupDialog(wx.Dialog):
def __init__(self,parent,content = None):
wx.Dialog.__init__(self,parent,-1,'', style = wx.BORDER_SIMPLE|wx.STAY_ON_TOP)
#---------------------------------------------------------------------------
-class wxPopupControl(wx.PyControl):
+class PopupControl(wx.PyControl):
def __init__(self,*_args,**_kwargs):
if _kwargs.has_key('value'):
del _kwargs['value']
def OnButton(self,evt):
if not self.pop:
if self.content:
- self.pop = wxPopupDialog(self,self.content)
+ self.pop = PopupDialog(self,self.content)
del self.content
else:
print 'No Content to pop'
# an alias
-wxPopupCtrl = wxPopupControl
+PopupCtrl = PopupControl
# o 2.5 compatability update.
# o Added deprecation warning.
#
+# 12/20/2003 - Jeff Grimmett (grimmtooth@softhome.net)
+#
+# o wxRightTextCtrl -> RightTextCtrl
+#
"""
Some time ago, I asked about how to right-align
#----------------------------------------------------------------------
-class wxRightTextCtrl(wx.TextCtrl):
+class RightTextCtrl(wx.TextCtrl):
def __init__(self, parent, id, *args, **kwargs):
wx.TextCtrl.__init__(self, parent, id, *args, **kwargs)
self.Bind(wx.EVT_KILL_FOCUS, self.OnKillFocus)
#----------------------------------------------------------------------------
-# Name: wxScrolledPanel.py
+# Name: scrolledpanel.py
# Author: Will Sadkin
# Created: 03/21/2003
# Copyright: (c) 2003 by Will Sadkin
#
# o 2.5 compatability update.
#
+# 12/21/2003 - Jeff Grimmett (grimmtooth@softhome.net)
+#
+# o wxScrolledPanel -> ScrolledPanel
+#
import wx
-class wxScrolledPanel( wx.ScrolledWindow ):
+class ScrolledPanel( wx.ScrolledWindow ):
"""\
-wxScrolledPanel fills a "hole" in the implementation of wxScrolledWindow,
+ScrolledPanel fills a "hole" in the implementation of wx.ScrolledWindow,
providing automatic scrollbar and scrolling behavior and the tab traversal
management that wxScrolledWindow lacks. This code was based on the original
demo code showing how to do this, but is now available for general use
"""
This function sets up the event handling necessary to handle
scrolling properly. It should be called within the __init__
- function of any class that is derived from wxScrolledPanel,
+ function of any class that is derived from ScrolledPanel,
once the controls on the panel have been constructed and
thus the size of the scrolling area can be determined.
#----------------------------------------------------------------------------
-# Name: wxTimeCtrl.py
+# Name: timectrl.py
# Author: Will Sadkin
# Created: 09/19/2002
# Copyright: (c) 2002 by Will Sadkin, 2002
# component of that control is inaccessible through the interface exposed in
# wxPython.
#
-# wxTimeCtrl does not use validators, because it does careful manipulation
+# TimeCtrl does not use validators, because it does careful manipulation
# of the cursor in the text window on each keystroke, and validation is
# cursor-position specific, so the control intercepts the key codes before the
# validator would fire.
#
-# wxTimeCtrl now also supports .SetValue() with either strings or wxDateTime
+# TimeCtrl now also supports .SetValue() with either strings or wxDateTime
# values, as well as range limits, with the option of either enforcing them
# or simply coloring the text of the control if the limits are exceeded.
#
# lock up. Noted in other places using it too, it's not this module
# that's at fault.
#
+# 12/20/2003 - Jeff Grimmett (grimmtooth@softhome.net)
+#
+# o wxMaskedTextCtrl -> MaskedTextCtrl
+# o wxTimeCtrl -> TimeCtrl
+#
"""<html><body>
<P>
-<B>wxTimeCtrl</B> provides a multi-cell control that allows manipulation of a time
+<B>TimeCtrl</B> provides a multi-cell control that allows manipulation of a time
value. It supports 12 or 24 hour format, and you can use wxDateTime or mxDateTime
to get/set values from the control.
<P>
-Left/right/tab keys to switch cells within a wxTimeCtrl, and the up/down arrows act
-like a spin control. wxTimeCtrl also allows for an actual spin button to be attached
+Left/right/tab keys to switch cells within a TimeCtrl, and the up/down arrows act
+like a spin control. TimeCtrl also allows for an actual spin button to be attached
to the control, so that it acts like the up/down arrow keys.
<P>
The <B>!</B> or <B>c</B> key sets the value of the control to the current time.
<P>
-Here's the API for wxTimeCtrl:
+Here's the API for TimeCtrl:
<DL><PRE>
- <B>wxTimeCtrl</B>(
+ <B>TimeCtrl</B>(
parent, id = -1,
<B>value</B> = '12:00:00 AM',
pos = wxDefaultPosition,
<DD>The size of the control will be automatically adjusted for 12/24 hour format
if wxDefaultSize is specified.
<DT><B>style</B>
- <DD>By default, wxTimeCtrl will process TAB events, by allowing tab to the
+ <DD>By default, TimeCtrl will process TAB events, by allowing tab to the
different cells within the control.
<DT><B>validator</B>
- <DD>By default, wxTimeCtrl just uses the default (empty) validator, as all
+ <DD>By default, TimeCtrl just uses the default (empty) validator, as all
of its validation for entry control is handled internally. However, a validator
can be supplied to provide data transfer capability to the control.
<BR>
<BR>
<DT><B>spinButton</B>
<DD>If specified, this button's events will be bound to the behavior of the
- wxTimeCtrl, working like up/down cursor key events. (See BindSpinButton.)
+ TimeCtrl, working like up/down cursor key events. (See BindSpinButton.)
<BR>
<DT><B>min</B>
<DD>Defines the lower bound for "valid" selections in the control.
- By default, wxTimeCtrl doesn't have bounds. You must set both upper and lower
+ By default, TimeCtrl doesn't have bounds. You must set both upper and lower
bounds to make the control pay attention to them, (as only one bound makes no sense
with times.) "Valid" times will fall between the min and max "pie wedge" of the
clock.
import wx
from wx.tools.dbg import Logger
-from wx.lib.maskededit import wxMaskedTextCtrl, Field
+from wx.lib.maskededit import MaskedTextCtrl, Field
dbg = Logger()
dbg(enable=0)
return self.value
-class wxTimeCtrl(wxMaskedTextCtrl):
+class TimeCtrl(MaskedTextCtrl):
valid_ctrl_params = {
'display_seconds' : True, # by default, shows seconds
'max': None,
'limited': False, # by default, no limiting even if bounds set
'useFixedWidthFont': True, # by default, use a fixed-width font
- 'oob_color': "Yellow" # by default, the default wxMaskedTextCtrl "invalid" color
+ 'oob_color': "Yellow" # by default, the default MaskedTextCtrl "invalid" color
}
def __init__ (
# set defaults for control:
dbg('setting defaults:')
- for key, param_value in wxTimeCtrl.valid_ctrl_params.items():
+ for key, param_value in TimeCtrl.valid_ctrl_params.items():
# This is done this way to make setattr behave consistently with
# "private attribute" name mangling
- setattr(self, "_wxTimeCtrl__" + key, copy.copy(param_value))
+ setattr(self, "_TimeCtrl__" + key, copy.copy(param_value))
# create locals from current defaults, so we can override if
# specified in kwargs, and handle uniformly:
# assign keyword args as appropriate:
for key, param_value in kwargs.items():
- if key not in wxTimeCtrl.valid_ctrl_params.keys():
+ if key not in TimeCtrl.valid_ctrl_params.keys():
raise AttributeError('invalid keyword argument "%s"' % key)
if key == "display_seconds":
maskededit_kwargs['formatcodes'] = 'T!'
# Now we can initialize the base control:
- wxMaskedTextCtrl.__init__(
+ MaskedTextCtrl.__init__(
self, parent, id=id,
pos=pos, size=size,
style = style,
self.Bind(wx.EVT_LEFT_DCLICK, self._OnDoubleClick ) ## select field under cursor on dclick
self.Bind(wx.EVT_KEY_DOWN, self._OnKeyDown ) ## capture control events not normally seen, eg ctrl-tab.
self.Bind(wx.EVT_CHAR, self.__OnChar ) ## remove "shift" attribute from colon key event,
- ## then call wxMaskedTextCtrl._OnChar with
+ ## then call MaskedTextCtrl._OnChar with
## the possibly modified event.
self.Bind(wx.EVT_TEXT, self.__OnTextChange, self ) ## color control appropriately and EVT_TIMEUPDATE events
This function binds an externally created spin button to the control, so that
up/down events from the button automatically change the control.
"""
- dbg('wxTimeCtrl::BindSpinButton')
+ dbg('TimeCtrl::BindSpinButton')
self.__spinButton = sb
if self.__spinButton:
# bind event handlers to spin ctrl
def __repr__(self):
- return "<wxTimeCtrl: %s>" % self.GetValue()
+ return "<TimeCtrl: %s>" % self.GetValue()
def SetValue(self, value):
and convert wxDateTime, mxDateTime, or 12/24 format time string
into the appropriate format string for the control.
"""
- dbg('wxTimeCtrl::SetValue(%s)' % repr(value), indent=1)
+ dbg('TimeCtrl::SetValue(%s)' % repr(value), indent=1)
try:
strtime = self._toGUI(self.__validateValue(value))
except:
elif as_mxDateTimeDelta:
value = DateTime.DateTimeDelta(0, value.GetHour(), value.GetMinute(), value.GetSecond())
else:
- value = wxMaskedTextCtrl.GetValue(self)
+ value = MaskedTextCtrl.GetValue(self)
return value
def GetWxDateTime(self, value=None):
"""
- This function is the conversion engine for wxTimeCtrl; it takes
+ This function is the conversion engine for TimeCtrl; it takes
one of the following types:
time string
wxDateTime
"""
global accept_mx
dbg(suspend=1)
- dbg('wxTimeCtrl::GetWxDateTime(%s)' % repr(value), indent=1)
+ dbg('TimeCtrl::GetWxDateTime(%s)' % repr(value), indent=1)
if value is None:
dbg('getting control value')
value = self.GetValue()
adjusted to the new minimum value; if not limited, the value in the
control will be colored as invalid.
"""
- dbg('wxTimeCtrl::SetMin(%s)'% repr(min), indent=1)
+ dbg('TimeCtrl::SetMin(%s)'% repr(min), indent=1)
if min is not None:
try:
min = self.GetWxDateTime(min)
by default, or as a string if as_string argument is True.
"""
dbg(suspend=1)
- dbg('wxTimeCtrl::GetMin, as_string?', as_string, indent=1)
+ dbg('TimeCtrl::GetMin, as_string?', as_string, indent=1)
if self.__min is None:
dbg('(min == None)')
ret = self.__min
adjusted to this maximum value; if not limited, the value in the
control will be colored as invalid.
"""
- dbg('wxTimeCtrl::SetMax(%s)' % repr(max), indent=1)
+ dbg('TimeCtrl::SetMax(%s)' % repr(max), indent=1)
if max is not None:
try:
max = self.GetWxDateTime(max)
by default, or as a string if as_string argument is True.
"""
dbg(suspend=1)
- dbg('wxTimeCtrl::GetMin, as_string?', as_string, indent=1)
+ dbg('TimeCtrl::GetMin, as_string?', as_string, indent=1)
if self.__max is None:
dbg('(max == None)')
ret = self.__max
limiting, but coloring of out-of-bounds values will still take
place if bounds have been set for the control.
"""
- dbg('wxTimeCtrl::SetLimited(%d)' % limited, indent=1)
+ dbg('TimeCtrl::SetLimited(%d)' % limited, indent=1)
self.__limited = limited
if not limited:
dbg('ValueError getting wxDateTime for %s' % repr(value), indent=0)
raise
- dbg('wxTimeCtrl::IsInBounds(%s)' % repr(value), indent=1)
+ dbg('TimeCtrl::IsInBounds(%s)' % repr(value), indent=1)
if self.__min is None or self.__max is None:
dbg(indent=0)
return True
def __OnTextChange(self, event=None):
- dbg('wxTimeCtrl::OnTextChange', indent=1)
+ dbg('TimeCtrl::OnTextChange', indent=1)
# Allow wxMaskedtext base control to color as appropriate,
# and Skip the EVT_TEXT event (if appropriate.)
## event iff the value has actually changed. The masked edit
## OnTextChange routine does this, and returns True on a valid event,
## False otherwise.
- if not wxMaskedTextCtrl._OnTextChange(self, event):
+ if not MaskedTextCtrl._OnTextChange(self, event):
return
dbg('firing TimeUpdatedEvent...')
This is necessary to handle the optional spin button, because the insertion
point is lost when the focus shifts to the spin button.
"""
- dbg('wxTimeCtrl::SetInsertionPoint', pos, indent=1)
- wxMaskedTextCtrl.SetInsertionPoint(self, pos) # (causes EVT_TEXT event to fire)
+ dbg('TimeCtrl::SetInsertionPoint', pos, indent=1)
+ MaskedTextCtrl.SetInsertionPoint(self, pos) # (causes EVT_TEXT event to fire)
self.__posCurrent = self.GetInsertionPoint()
dbg(indent=0)
def SetSelection(self, sel_start, sel_to):
- dbg('wxTimeCtrl::SetSelection', sel_start, sel_to, indent=1)
+ dbg('TimeCtrl::SetSelection', sel_start, sel_to, indent=1)
# Adjust selection range to legal extent if not already
if sel_start < 0:
sel_to = cell_end
self.__bSelection = sel_start != sel_to
- wxMaskedTextCtrl.SetSelection(self, sel_start, sel_to)
+ MaskedTextCtrl.SetSelection(self, sel_start, sel_to)
dbg(indent=0)
Event handler for any bound spin button on EVT_SPIN_UP;
causes control to behave as if up arrow was pressed.
"""
- dbg('wxTimeCtrl::OnSpinUp', indent=1)
+ dbg('TimeCtrl::OnSpinUp', indent=1)
self.__OnSpin(WXK_UP)
keep_processing = False
dbg(indent=0)
Event handler for any bound spin button on EVT_SPIN_DOWN;
causes control to behave as if down arrow was pressed.
"""
- dbg('wxTimeCtrl::OnSpinDown', indent=1)
+ dbg('TimeCtrl::OnSpinDown', indent=1)
self.__OnSpin(WXK_DOWN)
keep_processing = False
dbg(indent=0)
It then calls the base control's _OnChar routine with the modified
event instance.
"""
- dbg('wxTimeCtrl::OnChar', indent=1)
+ dbg('TimeCtrl::OnChar', indent=1)
keycode = event.GetKeyCode()
dbg('keycode:', keycode)
if keycode == ord(':'):
dbg('colon seen! removing shift attribute')
event.m_shiftDown = False
- wxMaskedTextCtrl._OnChar(self, event ) ## handle each keypress
+ MaskedTextCtrl._OnChar(self, event ) ## handle each keypress
dbg(indent=0)
Event handler for motion events; this handler
changes limits the selection to the new cell boundaries.
"""
- dbg('wxTimeCtrl::LimitSelection', indent=1)
+ dbg('TimeCtrl::LimitSelection', indent=1)
pos = self.GetInsertionPoint()
self.__posCurrent = pos
sel_start, sel_to = self.GetSelection()
def __IncrementValue(self, key, pos):
- dbg('wxTimeCtrl::IncrementValue', key, pos, indent=1)
+ dbg('TimeCtrl::IncrementValue', key, pos, indent=1)
text = self.GetValue()
field = self._FindField(pos)
dbg('field: ', field._index)
not a valid value for the control as currently specified.
It is used by both the SetValue() and the IsValid() methods.
"""
- dbg('wxTimeCtrl::__validateValue(%s)' % repr(value), indent=1)
+ dbg('TimeCtrl::__validateValue(%s)' % repr(value), indent=1)
if not value:
dbg(indent=0)
raise ValueError('%s not a valid time value' % repr(value))
return value
#----------------------------------------------------------------------------
-# Test jig for wxTimeCtrl:
+# Test jig for TimeCtrl:
if __name__ == '__main__':
import traceback
self.test_mx = test_mx
- self.tc = wxTimeCtrl(self, 10, fmt24hr = fmt24hr)
+ self.tc = TimeCtrl(self, 10, fmt24hr = fmt24hr)
sb = wx.SpinButton( self, 20, wx.DefaultPosition, (-1,20), 0 )
self.tc.BindSpinButton(sb)
fmt24hr = '24' in sys.argv
test_mx = 'mx' in sys.argv
try:
- frame = wx.Frame(None, -1, "wxTimeCtrl Test", (20,20), (100,100) )
+ frame = wx.Frame(None, -1, "TimeCtrl Test", (20,20), (100,100) )
panel = TestPanel(frame, -1, (-1,-1), fmt24hr=fmt24hr, test_mx = test_mx)
frame.Show(True)
except:
# Copyright: (c) 2002 by Will Sadkin, 2002
# License: wxWindows license
#----------------------------------------------------------------------------
+# 12/21/2003 - Jeff Grimmett (grimmtooth@softhome.net)
+#
+# o V2.5 compatability update
+#
"""
This module provides a useful debugging framework that supports
#------------------------------------------------------------
if __name__ == "__main__":
- from wxPython.wx import *
- wxLog_SetActiveTarget( wxLogStderr() )
+ import sys
+ import wx
+
+ wx.Log_SetActiveTarget( wx.LogStderr() )
logger = Logger('module')
dbg = logger.dbg
dbg(enable=1)
logger('test __call__ interface')
dbg('testing wxLog output to stderr:', wxlog=1, indent=1)
dbg('1,2,3...')
- dbg('testing wxLogNull:')
- devnull = wxLogNull()
+ dbg('testing wx.LogNull:')
+ devnull = wx.LogNull()
dbg('4,5,6...') # shouldn't print, according to doc...
del devnull
- dbg('(resuming to wxLogStdErr)', '7,8,9...', indent=0)
- dbg('disabling wxLog output, switching to stderr:')
+ dbg('(resuming to wx.LogStdErr)', '7,8,9...', indent=0)
+ dbg('disabling wx.Log output, switching to stderr:')
dbg(wxlog=0, stream=sys.stderr)
dbg(logger._outstream, 'switching back to stdout:')
dbg(stream=None)
# Copyright: (c) 2002 by Total Control Software
# Licence: wxWindows license
#----------------------------------------------------------------------
+# 12/21/2003 - Jeff Grimmett (grimmtooth@softhome.net)
+#
+# o V2.5 compatability update
+#
+import getopt
+import glob
+import os
+import sys
-import sys, os, glob, getopt
-from wxPython.wx import *
-
+import wx
def convert(file, maskClr, outputDir, outputName, outType, outExt):
if os.path.splitext(file)[1].lower() == ".ico":
- icon = wxIcon(file, wxBITMAP_TYPE_ICO)
- img = wxBitmapFromIcon(icon)
+ icon = wx.Icon(file, wx.BITMAP_TYPE_ICO)
+ img = wx.BitmapFromIcon(icon)
else:
- img = wxBitmap(file, wxBITMAP_TYPE_ANY)
+ img = wx.Bitmap(file, wx.BITMAP_TYPE_ANY)
if not img.Ok():
return 0, file + " failed to load!"
else:
if maskClr:
om = img.GetMask()
- mask = wxMaskColour(img, maskClr)
+ mask = wx.MaskColour(img, maskClr)
img.SetMask(mask)
if om is not None:
om.Destroy()
if img.SaveFile(newname, outType):
return 1, file + " converted to " + newname
else:
- img = wxImageFromBitmap(img)
+ img = wx.ImageFromBitmap(img)
if img.SaveFile(newname, outType):
return 1, "ok"
else:
# Copyright: (c) 2002 by Total Control Software
# Licence: wxWindows license
#----------------------------------------------------------------------
+# 12/21/2003 - Jeff Grimmett (grimmtooth@softhome.net)
+#
+# o V2.5 compatability update
+#
"""
img2png.py -- convert several image formats to PNG format
"""
-import sys
-import img2img
-from wxPython import wx
+import sys
+import wx
+import img2img
+
def main():
# some bitmap related things need to have a wxApp initialized...
- if wx.wxGetApp() is None:
- app = wx.wxPySimpleApp()
- img2img.main(sys.argv[1:], wx.wxBITMAP_TYPE_PNG, ".png", __doc__)
+ if wx.GetApp() is None:
+ app = wx.PySimpleApp()
+ img2img.main(sys.argv[1:], wx.BITMAP_TYPE_PNG, ".png", __doc__)
if __name__ == '__main__':
main()
# Copyright: (c) 2002 by Total Control Software
# Licence: wxWindows license
#----------------------------------------------------------------------
+# 12/21/2003 - Jeff Grimmett (grimmtooth@softhome.net)
+#
+# o V2.5 compatability update
+#
"""
# - Cliff Wells <LogiplexSoftware@earthlink.net>
# 20021206: Added catalog (-c) option.
#
+# 12/21/2003 - Jeff Grimmett (grimmtooth@softhome.net)
+#
+# o V2.5 compatability update
+#
+
+import cPickle
+import cStringIO
+import getopt
+import glob
+import os
+import sys
+import tempfile
+import zlib
+import wx
-import sys, os, glob, getopt, tempfile
-import cPickle, cStringIO, zlib
-import img2img
-from wxPython import wx
+import img2img
def crunch_data(data, compressed):
return
# some bitmap related things need to have a wxApp initialized...
- if wx.wxGetApp() is None:
- app = wx.wxPySimpleApp()
+ if wx.GetApp() is None:
+ app = wx.PySimpleApp()
append = 0
compressed = 1
# convert the image file to a temporary file
tfname = tempfile.mktemp()
- ok, msg = img2img.convert(image_file, maskClr, None, tfname, wx.wxBITMAP_TYPE_PNG, ".png")
+ ok, msg = img2img.convert(image_file, maskClr, None, tfname, wx.BITMAP_TYPE_PNG, ".png")
if not ok:
print msg
return
out.write("#" + "-" * 70 + "\n")
if not append:
out.write("# This file was generated by %s\n#\n" % sys.argv[0])
- out.write("from wxPython.wx import wxImageFromStream, wxBitmapFromImage\n")
+ out.write("from wx import ImageFromStream, BitmapFromImage\n")
if icon:
- out.write("from wxPython.wx import wxEmptyIcon\n")
+ out.write("from wx import EmptyIcon\n")
if compressed:
out.write("import cStringIO, zlib\n\n\n")
else:
out.write("def get%sBitmap():\n"
- " return wxBitmapFromImage(get%sImage())\n\n"
+ " return BitmapFromImage(get%sImage())\n\n"
"def get%sImage():\n"
" stream = cStringIO.StringIO(get%sData())\n"
- " return wxImageFromStream(stream)\n\n"
+ " return ImageFromStream(stream)\n\n"
% tuple([imgName] * 4))
if icon:
out.write("def get%sIcon():\n"
- " icon = wxEmptyIcon()\n"
+ " icon = EmptyIcon()\n"
" icon.CopyFromBitmap(get%sBitmap())\n"
" return icon\n\n"
% tuple([imgName] * 2))
# Copyright: (c) 2002 by Total Control Software
# Licence: wxWindows license
#----------------------------------------------------------------------
+# 12/21/2003 - Jeff Grimmett (grimmtooth@softhome.net)
+#
+# o V2.5 compatability update
+#
"""
img2xpm.py -- convert several image formats to XPM
the -o option.
"""
+import sys
+
+import wx
-import sys
-import img2img
-from wxPython import wx
+import img2img
def main():
# some bitmap related things need to have a wxApp initialized...
- if wx.wxGetApp() is None:
- app = wx.wxPySimpleApp()
- img2img.main(sys.argv[1:], wx.wxBITMAP_TYPE_XPM, ".xpm", __doc__)
+ if wx.GetApp() is None:
+ app = wx.PySimpleApp()
+ img2img.main(sys.argv[1:], wx.BITMAP_TYPE_XPM, ".xpm", __doc__)
if __name__ == '__main__':
__doc__ = wx.lib.colourchooser.pycolourchooser.__doc__
main = wx.lib.colourchooser.pycolourchooser.main
-wxPyColourChooser = wx.lib.colourchooser.pycolourchooser.wxPyColourChooser
+wxPyColourChooser = wx.lib.colourchooser.pycolourchooser.PyColourChooser
-from editor import wxEditor
+from editor import Editor
LineSplitter = wx.lib.editor.editor.LineSplitter
LineTrimmer = wx.lib.editor.editor.LineTrimmer
Scroller = wx.lib.editor.editor.Scroller
-wxEditor = wx.lib.editor.editor.wxEditor
+wxEditor = wx.lib.editor.editor.Editor
__doc__ = wx.lib.grids.__doc__
-wxFlexGridSizer = wx.lib.grids.wxFlexGridSizer
-wxGridSizer = wx.lib.grids.wxGridSizer
+wxFlexGridSizer = wx.lib.grids.PyFlexGridSizer
+wxGridSizer = wx.lib.grids.PyGridSizer
__doc__ = wx.lib.infoframe.__doc__
-Dummy_wxPyInformationalMessagesFrame = wx.lib.infoframe.Dummy_wxPyInformationalMessagesFrame
+Dummy_wxPyInformationalMessagesFrame = wx.lib.infoframe.Dummy_PyInformationalMessagesFrame
_MyStatusBar = wx.lib.infoframe._MyStatusBar
-wxPyInformationalMessagesFrame = wx.lib.infoframe.wxPyInformationalMessagesFrame
+wxPyInformationalMessagesFrame = wx.lib.infoframe.PyInformationalMessagesFrame
__doc__ = wx.lib.intctrl.__doc__
EVT_INT = wx.lib.intctrl.EVT_INT
-wxIntCtrl = wx.lib.intctrl.wxIntCtrl
-wxIntUpdatedEvent = wx.lib.intctrl.wxIntUpdatedEvent
-wxIntValidator = wx.lib.intctrl.wxIntValidator
+wxIntCtrl = wx.lib.intctrl.IntCtrl
+wxIntUpdatedEvent = wx.lib.intctrl.IntUpdatedEvent
+wxIntValidator = wx.lib.intctrl.IntValidator
__doc__ = wx.lib.maskedctrl.__doc__
controlTypes = wx.lib.maskedctrl.controlTypes
-wxMaskedCtrl = wx.lib.maskedctrl.wxMaskedCtrl
+wxMaskedCtrl = wx.lib.maskedctrl.MaskedCtrl
Field = wx.lib.maskededit.Field
test = wx.lib.maskededit.test
test2 = wx.lib.maskededit.test2
-wxIpAddrCtrl = wx.lib.maskededit.wxIpAddrCtrl
-wxMaskedComboBox = wx.lib.maskededit.wxMaskedComboBox
-wxMaskedComboBoxSelectEvent = wx.lib.maskededit.wxMaskedComboBoxSelectEvent
-wxMaskedEditMixin = wx.lib.maskededit.wxMaskedEditMixin
-wxMaskedTextCtrl = wx.lib.maskededit.wxMaskedTextCtrl
+wxIpAddrCtrl = wx.lib.maskededit.IpAddrCtrl
+wxMaskedComboBox = wx.lib.maskededit.MaskedComboBox
+wxMaskedComboBoxSelectEvent = wx.lib.maskededit.MaskedComboBoxSelectEvent
+wxMaskedEditMixin = wx.lib.maskededit.MaskedEditMixin
+wxMaskedTextCtrl = wx.lib.maskededit.MaskedTextCtrl
__doc__ = wx.lib.maskednumctrl.__doc__
EVT_MASKEDNUM = wx.lib.maskednumctrl.EVT_MASKEDNUM
-wxMaskedNumCtrl = wx.lib.maskednumctrl.wxMaskedNumCtrl
-wxMaskedNumNumberUpdatedEvent = wx.lib.maskednumctrl.wxMaskedNumNumberUpdatedEvent
+wxMaskedNumCtrl = wx.lib.maskednumctrl.MaskedNumCtrl
+wxMaskedNumNumberUpdatedEvent = wx.lib.maskednumctrl.MaskedNumNumberUpdatedEvent
__doc__ = wx.lib.mixins.grid.__doc__
-wxGridAutoEditMixin = wx.lib.mixins.grid.wxGridAutoEditMixin
+wxGridAutoEditMixin = wx.lib.mixins.grid.GridAutoEditMixin
ListCtrlSelectionManagerMix = wx.lib.mixins.listctrl.ListCtrlSelectionManagerMix
getListCtrlSelection = wx.lib.mixins.listctrl.getListCtrlSelection
selectBeforePopup = wx.lib.mixins.listctrl.selectBeforePopup
-wxColumnSorterMixin = wx.lib.mixins.listctrl.wxColumnSorterMixin
-wxListCtrlAutoWidthMixin = wx.lib.mixins.listctrl.wxListCtrlAutoWidthMixin
+wxColumnSorterMixin = wx.lib.mixins.listctrl.ColumnSorterMixin
+wxListCtrlAutoWidthMixin = wx.lib.mixins.listctrl.ListCtrlAutoWidthMixin
MultiCloser = wx.lib.multisash.MultiCloser
MultiCreator = wx.lib.multisash.MultiCreator
MultiSizer = wx.lib.multisash.MultiSizer
-wxMultiSash = wx.lib.multisash.wxMultiSash
-wxMultiSplit = wx.lib.multisash.wxMultiSplit
-wxMultiViewLeaf = wx.lib.multisash.wxMultiViewLeaf
+wxMultiSash = wx.lib.multisash.MultiSash
+wxMultiSplit = wx.lib.multisash.MultiSplit
+wxMultiViewLeaf = wx.lib.multisash.MultiViewLeaf
TreeLinePainter = wx.lib.mvctree.TreeLinePainter
TreeNodePainter = wx.lib.mvctree.TreeNodePainter
TreePainter = wx.lib.mvctree.TreePainter
-wxMVCTree = wx.lib.mvctree.wxMVCTree
-wxMVCTreeEvent = wx.lib.mvctree.wxMVCTreeEvent
-wxMVCTreeNotifyEvent = wx.lib.mvctree.wxMVCTreeNotifyEvent
-wxTreeModel = wx.lib.mvctree.wxTreeModel
+wxMVCTree = wx.lib.mvctree.MVCTree
+wxMVCTreeEvent = wx.lib.mvctree.MVCTreeEvent
+wxMVCTreeNotifyEvent = wx.lib.mvctree.MVCTreeNotifyEvent
+wxTreeModel = wx.lib.mvctree.TreeModel
--- /dev/null
+## This file imports items from the wx package into the wxPython package for
+## backwards compatibility. Some names will also have a 'wx' added on if
+## that is how they used to be named in the old wxPython package.
+
+import wx.lib.plot
+
+__doc__ = wx.lib.plot.__doc__
+
+PolyPoints = wx.lib.plot.PolyPoints
+PolyLine = wx.lib.plot.PolyLine
+PolyMarker = wx.lib.plot.PolyMarker
+PlotGraphics = wx.lib.plot.PlotGraphics
+PlotCanvas = wx.lib.plot.PlotCanvas
+PlotPrintout = wx.lib.plot.PlotPrintout
+FloatDCWrapper = wx.lib.plot.FloatDCWrapper
+_draw1Objects = wx.lib.plot._draw1Objects
+_draw2Objects = wx.lib.plot._draw2Objects
+_draw3Objects = wx.lib.plot._draw3Objects
+_draw4Objects = wx.lib.plot._draw4Objects
+_draw5Objects = wx.lib.plot._draw5Objects
+__test = wx.lib.plot.__test
+
PopButton = wx.lib.popupctl.PopButton
wxPopupControl = wx.lib.popupctl.wxPopupControl
-wxPopupCtrl = wx.lib.popupctl.wxPopupCtrl
-wxPopupDialog = wx.lib.popupctl.wxPopupDialog
+wxPopupCtrl = wx.lib.popupctl.PopupCtrl
+wxPopupControl = wx.lib.popupctl.PopupControl
+wxPopupDialog = wx.lib.popupctl.PopupDialog
__doc__ = wx.lib.rightalign.__doc__
-wxRightTextCtrl = wx.lib.rightalign.wxRightTextCtrl
+wxRightTextCtrl = wx.lib.rightalign.RightTextCtrl
__doc__ = wx.lib.scrolledpanel.__doc__
-wxScrolledPanel = wx.lib.scrolledpanel.wxScrolledPanel
+wxScrolledPanel = wx.lib.scrolledpanel.ScrolledPanel
EVT_TIMEUPDATE = wx.lib.timectrl.EVT_TIMEUPDATE
TimeUpdatedEvent = wx.lib.timectrl.TimeUpdatedEvent
-wxTimeCtrl = wx.lib.timectrl.wxTimeCtrl
+wxTimeCtrl = wx.lib.timectrl.TimeCtrl
--- /dev/null
+## This file imports items from the wx package into the wxPython package for
+## backwards compatibility. Some names will also have a 'wx' added on if
+## that is how they used to be named in the old wxPython package.
+
+import wx.lib.wxPlotCanvas
+
+__doc__ = wx.lib.wxPlotCanvas.__doc__
+
+PolyPoints = wx.lib.wxPlotCanvas.PolyPoints
+PolyLine = wx.lib.wxPlotCanvas.PolyLine
+PolyMarker = wx.lib.wxPlotCanvas.PolyMarker
+PlotGraphics = wx.lib.wxPlotCanvas.PlotGraphics
+PlotCanvas = wx.lib.wxPlotCanvas.PlotCanvas