More lib and demo patches to drop the wx prefix (Jeff has been busy!)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@24965 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
"""
|
||||
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,
|
||||
@@ -16,11 +16,16 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
#
|
||||
# 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',
|
||||
|
@@ -1,10 +1,10 @@
|
||||
"""
|
||||
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,
|
||||
@@ -16,6 +16,11 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
#
|
||||
# o 2.5 compatability update.
|
||||
#
|
||||
# 12/21/2003 - Jeff Grimmett (grimmtooth@softhome.net)
|
||||
#
|
||||
# o wxPyColorChooser -> PyColorChooser
|
||||
# o wxPyColourChooser -> PyColourChooser
|
||||
#
|
||||
|
||||
import wx
|
||||
|
||||
|
@@ -1,10 +1,10 @@
|
||||
"""
|
||||
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,
|
||||
@@ -15,8 +15,8 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
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 }
|
||||
|
@@ -1,10 +1,10 @@
|
||||
"""
|
||||
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,
|
||||
@@ -15,6 +15,11 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
#
|
||||
# o 2.5 compatability update.
|
||||
#
|
||||
# 12/21/2003 - Jeff Grimmett (grimmtooth@softhome.net)
|
||||
#
|
||||
# o wxPyColorChooser -> PyColorChooser
|
||||
# o wxPyColourChooser -> PyColourChooser
|
||||
#
|
||||
|
||||
import wx
|
||||
|
||||
|
@@ -1,10 +1,10 @@
|
||||
"""
|
||||
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,
|
||||
@@ -16,6 +16,13 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
#
|
||||
# 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
|
||||
|
||||
@@ -27,7 +34,7 @@ import intl
|
||||
|
||||
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
|
||||
@@ -383,7 +390,13 @@ def main():
|
||||
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)
|
||||
|
@@ -1,14 +1,14 @@
|
||||
"""
|
||||
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,
|
||||
@@ -20,6 +20,11 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
#
|
||||
# o 2.5 compatability update.
|
||||
#
|
||||
# 12/21/2003 - Jeff Grimmett (grimmtooth@softhome.net)
|
||||
#
|
||||
# o wxPyColorChooser -> PyColorChooser
|
||||
# o wxPyColourChooser -> PyColourChooser
|
||||
#
|
||||
|
||||
import wx
|
||||
|
||||
|
@@ -1,14 +1,14 @@
|
||||
"""
|
||||
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,
|
||||
@@ -19,6 +19,13 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
#
|
||||
# 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
|
||||
@@ -164,7 +171,12 @@ class PyPalette(canvas.Canvas):
|
||||
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))
|
||||
|
||||
|
@@ -13,9 +13,13 @@
|
||||
#
|
||||
# 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
|
||||
|
@@ -1,5 +1,5 @@
|
||||
#----------------------------------------------------------------------
|
||||
# Name: wxPython.lib.editor.wxEditor
|
||||
# Name: wxPython.lib.editor.Editor
|
||||
# Purpose: An intelligent text editor with colorization capabilities.
|
||||
#
|
||||
# Original
|
||||
@@ -24,6 +24,10 @@
|
||||
#
|
||||
# o 2.5 compatability update.
|
||||
#
|
||||
# 12/21/2003 - Jeff Grimmett (grimmtooth@softhome.net)
|
||||
#
|
||||
# o wxEditor -> Editor
|
||||
#
|
||||
|
||||
import os
|
||||
import time
|
||||
@@ -75,7 +79,7 @@ class Scroller:
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
class wxEditor(wx.ScrolledWindow):
|
||||
class Editor(wx.ScrolledWindow):
|
||||
|
||||
def __init__(self, parent, id,
|
||||
pos=wx.DefaultPosition, size=wx.DefaultSize, style=0):
|
||||
|
@@ -14,15 +14,26 @@
|
||||
#
|
||||
# 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
|
||||
@@ -33,7 +44,7 @@ center of the space. When the sizer is resized, all the items are
|
||||
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.
|
||||
@@ -41,11 +52,28 @@ 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:
|
||||
@@ -171,7 +199,7 @@ class wxGridSizer(wx.PySizer):
|
||||
|
||||
|
||||
|
||||
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 = []
|
||||
|
@@ -124,7 +124,7 @@ class ImageDialog(wx.Dialog):
|
||||
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
|
||||
|
@@ -1,3 +1,9 @@
|
||||
# 12/20/2003 - Jeff Grimmett (grimmtooth@softhome.net)
|
||||
#
|
||||
# o wxPyInformationalMessagesFrame -> PyInformationalMessagesFrame
|
||||
# o dummy_wxPyInformationalMessagesFrame -> dummy_PyInformationalMessagesFrame
|
||||
#
|
||||
|
||||
"""
|
||||
infoframe.py
|
||||
Released under wxWindows license etc.
|
||||
@@ -30,7 +36,7 @@ Typical usage:
|
||||
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
|
||||
@@ -39,7 +45,7 @@ automatically for you on Windows).
|
||||
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"])
|
||||
@@ -192,7 +198,7 @@ class _MyStatusBar(wx.StatusBar):
|
||||
|
||||
|
||||
|
||||
class wxPyInformationalMessagesFrame:
|
||||
class PyInformationalMessagesFrame:
|
||||
def __init__(self,
|
||||
progname="",
|
||||
text="informational messages",
|
||||
@@ -456,7 +462,7 @@ class wxPyInformationalMessagesFrame:
|
||||
|
||||
|
||||
|
||||
class Dummy_wxPyInformationalMessagesFrame:
|
||||
class Dummy_PyInformationalMessagesFrame:
|
||||
def __init__(self,progname=""):
|
||||
self.softspace = 1
|
||||
def __call__(self,*args):
|
||||
|
@@ -9,7 +9,7 @@
|
||||
# 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.
|
||||
#
|
||||
@@ -21,7 +21,7 @@
|
||||
# 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.
|
||||
#----------------------------------------------------------------------------
|
||||
@@ -29,6 +29,12 @@
|
||||
#
|
||||
# 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
|
||||
@@ -59,7 +65,7 @@ EVT_INT = wx.PyEventBinder(wxEVT_COMMAND_INT_UPDATED, 1)
|
||||
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)
|
||||
|
||||
@@ -74,9 +80,9 @@ class wxIntUpdatedEvent(wx.PyCommandEvent):
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
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):
|
||||
@@ -341,12 +347,12 @@ class wxIntValidator( wx.PyValidator ):
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
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,
|
||||
@@ -404,10 +410,10 @@ class wxIntCtrl(wx.TextCtrl):
|
||||
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__ (
|
||||
@@ -431,7 +437,7 @@ class wxIntCtrl(wx.TextCtrl):
|
||||
self.__oldvalue = None
|
||||
|
||||
if validator == wx.DefaultValidator:
|
||||
validator = wxIntValidator()
|
||||
validator = IntValidator()
|
||||
|
||||
wx.TextCtrl.__init__(
|
||||
self, parent, id, self._toGUI(0),
|
||||
@@ -464,7 +470,7 @@ class wxIntCtrl(wx.TextCtrl):
|
||||
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
|
||||
@@ -632,7 +638,7 @@ class wxIntCtrl(wx.TextCtrl):
|
||||
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()
|
||||
@@ -729,10 +735,10 @@ class wxIntCtrl(wx.TextCtrl):
|
||||
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()
|
||||
@@ -850,7 +856,7 @@ if __name__ == '__main__':
|
||||
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")
|
||||
|
||||
@@ -883,7 +889,7 @@ if __name__ == '__main__':
|
||||
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)
|
||||
|
@@ -10,21 +10,25 @@
|
||||
#
|
||||
# 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:
|
||||
@@ -38,22 +42,22 @@ 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
|
||||
@@ -72,7 +76,7 @@ class controlTypes:
|
||||
NUMBER = NUMBER
|
||||
|
||||
|
||||
def wxMaskedCtrl( *args, **kwargs):
|
||||
def MaskedCtrl( *args, **kwargs):
|
||||
"""
|
||||
Actually a factory function providing a unifying
|
||||
interface for generating masked controls.
|
||||
@@ -84,19 +88,19 @@ def wxMaskedCtrl( *args, **kwargs):
|
||||
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(
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -9,10 +9,10 @@
|
||||
# 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.
|
||||
@@ -24,38 +24,45 @@
|
||||
# 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,
|
||||
@@ -361,7 +368,7 @@ MAXINT = maxint # (constants should be in upper case)
|
||||
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)
|
||||
@@ -373,7 +380,7 @@ EVT_MASKEDNUM = wx.PyEventBinder(wxEVT_COMMAND_MASKED_NUMBER_UPDATED, 1)
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
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)
|
||||
|
||||
@@ -388,7 +395,7 @@ class wxMaskedNumNumberUpdatedEvent(wx.PyCommandEvent):
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
class wxMaskedNumCtrl(wxMaskedTextCtrl):
|
||||
class MaskedNumCtrl(MaskedTextCtrl):
|
||||
|
||||
valid_ctrl_params = {
|
||||
'integerWidth': 10, # by default allow all 32-bit integers
|
||||
@@ -419,21 +426,21 @@ class wxMaskedNumCtrl(wxMaskedTextCtrl):
|
||||
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
|
||||
@@ -490,7 +497,7 @@ class wxMaskedNumCtrl(wxMaskedTextCtrl):
|
||||
self._typedSign = False
|
||||
|
||||
# Construct the base control:
|
||||
wxMaskedTextCtrl.__init__(
|
||||
MaskedTextCtrl.__init__(
|
||||
self, parent, id, '',
|
||||
pos, size, style, validator, name,
|
||||
mask = mask,
|
||||
@@ -517,14 +524,14 @@ class wxMaskedNumCtrl(wxMaskedTextCtrl):
|
||||
|
||||
# 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
|
||||
|
||||
@@ -596,9 +603,9 @@ class wxMaskedNumCtrl(wxMaskedTextCtrl):
|
||||
# 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)
|
||||
@@ -726,7 +733,7 @@ class wxMaskedNumCtrl(wxMaskedTextCtrl):
|
||||
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:
|
||||
@@ -746,7 +753,7 @@ class wxMaskedNumCtrl(wxMaskedTextCtrl):
|
||||
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)
|
||||
|
||||
|
||||
|
||||
@@ -768,7 +775,7 @@ class wxMaskedNumCtrl(wxMaskedTextCtrl):
|
||||
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()
|
||||
@@ -778,14 +785,14 @@ class wxMaskedNumCtrl(wxMaskedTextCtrl):
|
||||
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
|
||||
@@ -805,7 +812,7 @@ class wxMaskedNumCtrl(wxMaskedTextCtrl):
|
||||
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) ) :
|
||||
@@ -817,8 +824,8 @@ class wxMaskedNumCtrl(wxMaskedTextCtrl):
|
||||
|
||||
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():
|
||||
@@ -918,7 +925,7 @@ class wxMaskedNumCtrl(wxMaskedTextCtrl):
|
||||
# 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)
|
||||
@@ -944,18 +951,18 @@ class wxMaskedNumCtrl(wxMaskedTextCtrl):
|
||||
|
||||
|
||||
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 (' ', '-', '('):
|
||||
@@ -972,13 +979,13 @@ class wxMaskedNumCtrl(wxMaskedTextCtrl):
|
||||
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:
|
||||
@@ -1004,7 +1011,7 @@ class wxMaskedNumCtrl(wxMaskedTextCtrl):
|
||||
self.SetInsertionPoint(sel_start)
|
||||
self.SetSelection(sel_start, sel_to+1)
|
||||
|
||||
wxMaskedTextCtrl._OnErase(self, event)
|
||||
MaskedTextCtrl._OnErase(self, event)
|
||||
dbg(indent=0)
|
||||
|
||||
|
||||
@@ -1017,8 +1024,8 @@ class wxMaskedNumCtrl(wxMaskedTextCtrl):
|
||||
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
|
||||
|
||||
@@ -1028,7 +1035,7 @@ class wxMaskedNumCtrl(wxMaskedTextCtrl):
|
||||
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
|
||||
@@ -1039,7 +1046,7 @@ class wxMaskedNumCtrl(wxMaskedTextCtrl):
|
||||
|
||||
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)
|
||||
@@ -1049,7 +1056,7 @@ class wxMaskedNumCtrl(wxMaskedTextCtrl):
|
||||
"""
|
||||
Returns the current numeric value of the control.
|
||||
"""
|
||||
return self._fromGUI( wxMaskedTextCtrl.GetValue(self) )
|
||||
return self._fromGUI( MaskedTextCtrl.GetValue(self) )
|
||||
|
||||
def SetValue(self, value):
|
||||
"""
|
||||
@@ -1060,7 +1067,7 @@ class wxMaskedNumCtrl(wxMaskedTextCtrl):
|
||||
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):
|
||||
@@ -1091,7 +1098,7 @@ class wxMaskedNumCtrl(wxMaskedTextCtrl):
|
||||
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) ):
|
||||
@@ -1296,7 +1303,7 @@ class wxMaskedNumCtrl(wxMaskedTextCtrl):
|
||||
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
|
||||
@@ -1311,12 +1318,12 @@ class wxMaskedNumCtrl(wxMaskedTextCtrl):
|
||||
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 (
|
||||
@@ -1366,7 +1373,7 @@ class wxMaskedNumCtrl(wxMaskedTextCtrl):
|
||||
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.
|
||||
@@ -1419,7 +1426,7 @@ class wxMaskedNumCtrl(wxMaskedTextCtrl):
|
||||
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:
|
||||
@@ -1431,7 +1438,7 @@ class wxMaskedNumCtrl(wxMaskedTextCtrl):
|
||||
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)
|
||||
@@ -1450,7 +1457,7 @@ if __name__ == '__main__':
|
||||
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")
|
||||
|
||||
@@ -1483,7 +1490,7 @@ if __name__ == '__main__':
|
||||
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)
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#----------------------------------------------------------------------------
|
||||
# Name: wxPython.lib.mixins.grid
|
||||
# Purpose: Helpful mix-in classes for wxGrid
|
||||
# Purpose: Helpful mix-in classes for wx.Grid
|
||||
#
|
||||
# Author: Robin Dunn
|
||||
#
|
||||
@@ -14,6 +14,10 @@
|
||||
# o 2.5 compatability update.
|
||||
# o Untested
|
||||
#
|
||||
# 12/21/2003 - Jeff Grimmett (grimmtooth@softhome.net)
|
||||
#
|
||||
# o wxGridAutoEditMixin -> GridAutoEditMixin
|
||||
#
|
||||
|
||||
import wx
|
||||
import wx.grid
|
||||
@@ -21,7 +25,7 @@ import wx.grid
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
|
||||
class wxGridAutoEditMixin:
|
||||
class GridAutoEditMixin:
|
||||
"""A mix-in class that automatically enables the grid edit control when
|
||||
a cell is selected.
|
||||
|
||||
|
@@ -14,13 +14,18 @@
|
||||
# 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.
|
||||
@@ -144,7 +149,7 @@ class wxColumnSorterMixin:
|
||||
#----------------------------------------------------------------------------
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
class wxListCtrlAutoWidthMixin:
|
||||
class ListCtrlAutoWidthMixin:
|
||||
""" A mix-in class that automatically resizes the last column to take up
|
||||
the remaining width of the wx.ListCtrl.
|
||||
|
||||
|
@@ -7,12 +7,18 @@
|
||||
# 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
|
||||
|
||||
@@ -24,11 +30,11 @@ CR_SIZE = SH_SIZE * 3
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
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):
|
||||
@@ -43,7 +49,7 @@ class wxMultiSash(wx.Window):
|
||||
|
||||
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)
|
||||
|
||||
@@ -59,7 +65,7 @@ class wxMultiSash(wx.Window):
|
||||
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)
|
||||
@@ -69,7 +75,7 @@ class wxMultiSash(wx.Window):
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
|
||||
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)
|
||||
@@ -80,7 +86,7 @@ class wxMultiSplit(wx.Window):
|
||||
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
|
||||
|
||||
@@ -90,11 +96,11 @@ class wxMultiSplit(wx.Window):
|
||||
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()
|
||||
@@ -113,10 +119,10 @@ class wxMultiSplit(wx.Window):
|
||||
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:
|
||||
@@ -126,10 +132,10 @@ class wxMultiSplit(wx.Window):
|
||||
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:
|
||||
@@ -152,13 +158,13 @@ class wxMultiSplit(wx.Window):
|
||||
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)
|
||||
@@ -174,7 +180,7 @@ class wxMultiSplit(wx.Window):
|
||||
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)
|
||||
|
||||
@@ -281,7 +287,7 @@ class wxMultiSplit(wx.Window):
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
|
||||
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)
|
||||
|
@@ -3,15 +3,22 @@
|
||||
# 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
|
||||
@@ -57,7 +64,7 @@ warnings.warn(warningmsg, DeprecationWarning, stacklevel=2)
|
||||
|
||||
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.
|
||||
"""
|
||||
@@ -151,7 +158,7 @@ class Transform:
|
||||
|
||||
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):
|
||||
@@ -236,7 +243,7 @@ class Painter:
|
||||
evt.Skip()
|
||||
|
||||
|
||||
class wxTreeModel:
|
||||
class TreeModel:
|
||||
"""
|
||||
Interface for tree models
|
||||
"""
|
||||
@@ -305,7 +312,7 @@ class TextConverter:
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
class BasicTreeModel(wxTreeModel):
|
||||
class BasicTreeModel(TreeModel):
|
||||
"""
|
||||
A very simple treemodel implementation, but flexible enough for many needs.
|
||||
"""
|
||||
@@ -333,21 +340,21 @@ class BasicTreeModel(wxTreeModel):
|
||||
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):
|
||||
@@ -728,7 +735,7 @@ EVT_MVCTREE_ADD_ITEM = wx.PyEventBinder(wxEVT_MVCTREE_ADD_ITEM, 1)
|
||||
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
|
||||
@@ -741,14 +748,14 @@ class wxMVCTreeEvent(wx.PyCommandEvent):
|
||||
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.
|
||||
"""
|
||||
@@ -801,28 +808,28 @@ class wxMVCTree(wx.ScrolledWindow):
|
||||
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):
|
||||
@@ -862,7 +869,7 @@ class wxMVCTree(wx.ScrolledWindow):
|
||||
|
||||
def SetDoubleBuffered(self, bool):
|
||||
"""
|
||||
By default wxMVCTree is double-buffered.
|
||||
By default MVCTree is double-buffered.
|
||||
"""
|
||||
self.doubleBuffered = bool
|
||||
|
||||
@@ -923,7 +930,7 @@ class wxMVCTree(wx.ScrolledWindow):
|
||||
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
|
||||
@@ -934,7 +941,7 @@ class wxMVCTree(wx.ScrolledWindow):
|
||||
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):
|
||||
@@ -951,7 +958,7 @@ class wxMVCTree(wx.ScrolledWindow):
|
||||
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
|
||||
@@ -965,7 +972,7 @@ class wxMVCTree(wx.ScrolledWindow):
|
||||
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
|
||||
@@ -976,23 +983,23 @@ class wxMVCTree(wx.ScrolledWindow):
|
||||
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)
|
||||
@@ -1005,7 +1012,7 @@ class wxMVCTree(wx.ScrolledWindow):
|
||||
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
|
||||
@@ -1046,7 +1053,7 @@ class wxMVCTree(wx.ScrolledWindow):
|
||||
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)
|
||||
@@ -1064,7 +1071,7 @@ class wxMVCTree(wx.ScrolledWindow):
|
||||
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)
|
||||
|
@@ -13,6 +13,11 @@
|
||||
#
|
||||
# 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
|
||||
@@ -142,7 +147,7 @@ class PopButton(wx.PyControl):
|
||||
|
||||
|
||||
# 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)
|
||||
|
||||
@@ -187,7 +192,7 @@ class wxPopupDialog(wx.Dialog):
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
class wxPopupControl(wx.PyControl):
|
||||
class PopupControl(wx.PyControl):
|
||||
def __init__(self,*_args,**_kwargs):
|
||||
if _kwargs.has_key('value'):
|
||||
del _kwargs['value']
|
||||
@@ -216,7 +221,7 @@ class wxPopupControl(wx.PyControl):
|
||||
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'
|
||||
@@ -250,4 +255,4 @@ class wxPopupControl(wx.PyControl):
|
||||
|
||||
|
||||
# an alias
|
||||
wxPopupCtrl = wxPopupControl
|
||||
PopupCtrl = PopupControl
|
||||
|
@@ -16,6 +16,10 @@
|
||||
# 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
|
||||
@@ -60,7 +64,7 @@ warnings.warn(warningmsg, DeprecationWarning, stacklevel=2)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
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)
|
||||
|
@@ -1,5 +1,5 @@
|
||||
#----------------------------------------------------------------------------
|
||||
# Name: wxScrolledPanel.py
|
||||
# Name: scrolledpanel.py
|
||||
# Author: Will Sadkin
|
||||
# Created: 03/21/2003
|
||||
# Copyright: (c) 2003 by Will Sadkin
|
||||
@@ -10,13 +10,17 @@
|
||||
#
|
||||
# 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
|
||||
@@ -37,7 +41,7 @@ as a proper class (and the demo is now converted to just use it.)
|
||||
"""
|
||||
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.
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
#----------------------------------------------------------------------------
|
||||
# Name: wxTimeCtrl.py
|
||||
# Name: timectrl.py
|
||||
# Author: Will Sadkin
|
||||
# Created: 09/19/2002
|
||||
# Copyright: (c) 2002 by Will Sadkin, 2002
|
||||
@@ -13,12 +13,12 @@
|
||||
# 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.
|
||||
#
|
||||
@@ -37,22 +37,27 @@
|
||||
# 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,
|
||||
@@ -77,10 +82,10 @@ Here's the API for wxTimeCtrl:
|
||||
<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>
|
||||
@@ -91,11 +96,11 @@ Here's the API for wxTimeCtrl:
|
||||
<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.
|
||||
@@ -253,7 +258,7 @@ import types
|
||||
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)
|
||||
@@ -277,7 +282,7 @@ class TimeUpdatedEvent(wx.PyCommandEvent):
|
||||
return self.value
|
||||
|
||||
|
||||
class wxTimeCtrl(wxMaskedTextCtrl):
|
||||
class TimeCtrl(MaskedTextCtrl):
|
||||
|
||||
valid_ctrl_params = {
|
||||
'display_seconds' : True, # by default, shows seconds
|
||||
@@ -285,7 +290,7 @@ class wxTimeCtrl(wxMaskedTextCtrl):
|
||||
'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__ (
|
||||
@@ -300,10 +305,10 @@ class wxTimeCtrl(wxMaskedTextCtrl):
|
||||
|
||||
# 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:
|
||||
@@ -320,7 +325,7 @@ class wxTimeCtrl(wxMaskedTextCtrl):
|
||||
|
||||
# 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":
|
||||
@@ -383,7 +388,7 @@ class wxTimeCtrl(wxMaskedTextCtrl):
|
||||
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,
|
||||
@@ -420,7 +425,7 @@ class wxTimeCtrl(wxMaskedTextCtrl):
|
||||
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
|
||||
|
||||
@@ -443,7 +448,7 @@ class wxTimeCtrl(wxMaskedTextCtrl):
|
||||
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
|
||||
@@ -452,7 +457,7 @@ class wxTimeCtrl(wxMaskedTextCtrl):
|
||||
|
||||
|
||||
def __repr__(self):
|
||||
return "<wxTimeCtrl: %s>" % self.GetValue()
|
||||
return "<TimeCtrl: %s>" % self.GetValue()
|
||||
|
||||
|
||||
def SetValue(self, value):
|
||||
@@ -462,7 +467,7 @@ class wxTimeCtrl(wxMaskedTextCtrl):
|
||||
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:
|
||||
@@ -491,7 +496,7 @@ class wxTimeCtrl(wxMaskedTextCtrl):
|
||||
elif as_mxDateTimeDelta:
|
||||
value = DateTime.DateTimeDelta(0, value.GetHour(), value.GetMinute(), value.GetSecond())
|
||||
else:
|
||||
value = wxMaskedTextCtrl.GetValue(self)
|
||||
value = MaskedTextCtrl.GetValue(self)
|
||||
return value
|
||||
|
||||
|
||||
@@ -504,7 +509,7 @@ class wxTimeCtrl(wxMaskedTextCtrl):
|
||||
|
||||
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
|
||||
@@ -520,7 +525,7 @@ class wxTimeCtrl(wxMaskedTextCtrl):
|
||||
"""
|
||||
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()
|
||||
@@ -608,7 +613,7 @@ class wxTimeCtrl(wxMaskedTextCtrl):
|
||||
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)
|
||||
@@ -636,7 +641,7 @@ class wxTimeCtrl(wxMaskedTextCtrl):
|
||||
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
|
||||
@@ -667,7 +672,7 @@ class wxTimeCtrl(wxMaskedTextCtrl):
|
||||
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)
|
||||
@@ -695,7 +700,7 @@ class wxTimeCtrl(wxMaskedTextCtrl):
|
||||
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
|
||||
@@ -746,7 +751,7 @@ class wxTimeCtrl(wxMaskedTextCtrl):
|
||||
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:
|
||||
@@ -842,7 +847,7 @@ class wxTimeCtrl(wxMaskedTextCtrl):
|
||||
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
|
||||
@@ -889,7 +894,7 @@ class wxTimeCtrl(wxMaskedTextCtrl):
|
||||
|
||||
|
||||
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.)
|
||||
@@ -900,7 +905,7 @@ class wxTimeCtrl(wxMaskedTextCtrl):
|
||||
## 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...')
|
||||
@@ -916,14 +921,14 @@ class wxTimeCtrl(wxMaskedTextCtrl):
|
||||
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:
|
||||
@@ -936,7 +941,7 @@ class wxTimeCtrl(wxMaskedTextCtrl):
|
||||
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)
|
||||
|
||||
|
||||
@@ -961,7 +966,7 @@ class wxTimeCtrl(wxMaskedTextCtrl):
|
||||
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)
|
||||
@@ -973,7 +978,7 @@ class wxTimeCtrl(wxMaskedTextCtrl):
|
||||
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)
|
||||
@@ -987,13 +992,13 @@ class wxTimeCtrl(wxMaskedTextCtrl):
|
||||
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)
|
||||
|
||||
|
||||
@@ -1012,7 +1017,7 @@ class wxTimeCtrl(wxMaskedTextCtrl):
|
||||
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()
|
||||
@@ -1031,7 +1036,7 @@ class wxTimeCtrl(wxMaskedTextCtrl):
|
||||
|
||||
|
||||
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)
|
||||
@@ -1095,7 +1100,7 @@ class wxTimeCtrl(wxMaskedTextCtrl):
|
||||
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))
|
||||
@@ -1115,7 +1120,7 @@ class wxTimeCtrl(wxMaskedTextCtrl):
|
||||
return value
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test jig for wxTimeCtrl:
|
||||
# Test jig for TimeCtrl:
|
||||
|
||||
if __name__ == '__main__':
|
||||
import traceback
|
||||
@@ -1130,7 +1135,7 @@ if __name__ == '__main__':
|
||||
|
||||
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)
|
||||
|
||||
@@ -1160,7 +1165,7 @@ if __name__ == '__main__':
|
||||
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:
|
||||
|
Reference in New Issue
Block a user