dabo Commit
Revision 4796
Date: 2008-12-07 07:34:28 -0800 (Sun, 07 Dec 2008)
Author: Ed
Trac: http://trac.dabodev.com/dabo/changeset/4796
Changed:
U trunk/dabo/ui/uiwx/dBorderlessButton.py
U trunk/dabo/ui/uiwx/dDateTextBox.py
U trunk/dabo/ui/uiwx/dMaskedTextBox.py
U trunk/dabo/ui/uiwx/test.py
Log:
Added the ValueMode property to dMaskedTextBox. This will control whether the
Value property returns the masked value or the plain value. Default is plain.
Improved the import logic in test.py. Also fixed the import of
dBorderlessButton so that when it is run inside of test.py it doesn't break the
test.
Added a check for non-date values in dDateTextBox to prevent the errors
reported earlier this week.
Diff:
Modified: trunk/dabo/ui/uiwx/dBorderlessButton.py
===================================================================
--- trunk/dabo/ui/uiwx/dBorderlessButton.py 2008-12-07 14:56:02 UTC (rev
4795)
+++ trunk/dabo/ui/uiwx/dBorderlessButton.py 2008-12-07 15:34:28 UTC (rev
4796)
@@ -1,6 +1,10 @@
# -*- coding: utf-8 -*-
-import wx.lib.platebtn as platebtn
+import sys
import wx
+try:
+ import wx.lib.platebtn as platebtn
+except ImportError:
+ raise ImportError, "Your version of wxPython is too old for
dBorderlessButton"
import dabo
import dabo.ui
Modified: trunk/dabo/ui/uiwx/dDateTextBox.py
===================================================================
--- trunk/dabo/ui/uiwx/dDateTextBox.py 2008-12-07 14:56:02 UTC (rev 4795)
+++ trunk/dabo/ui/uiwx/dDateTextBox.py 2008-12-07 15:34:28 UTC (rev 4796)
@@ -206,7 +206,13 @@
shortcut keys.
"""
# Save the original value for comparison
- orig = self.Value.toordinal()
+ try:
+ orig = self.Value.toordinal()
+ except AttributeError:
+ # Value isn't a date for some reason
+ val = self.Value
+ dabo.errorLog.write(_("Non-date value in %s: '%s' is
type '%s'") % (self.Name, val, type(val)))
+ return
# Default direction
forward = True
# Flag to indicate errors in date processing
Modified: trunk/dabo/ui/uiwx/dMaskedTextBox.py
===================================================================
--- trunk/dabo/ui/uiwx/dMaskedTextBox.py 2008-12-07 14:56:02 UTC (rev
4795)
+++ trunk/dabo/ui/uiwx/dMaskedTextBox.py 2008-12-07 15:34:28 UTC (rev
4796)
@@ -7,7 +7,6 @@
dabo.ui.loadUI("wx")
import dabo.dEvents as dEvents
from dabo.dLocalize import _
-from dTextBox import dTextBox
from dabo.ui import makeDynamicProperty
import dTextBoxMixin as tbm
@@ -67,6 +66,7 @@
def __init__(self, parent, properties=None, attProperties=None, *args,
**kwargs):
self._baseClass = dMaskedTextBox
+ self._valueMode = None
self._mask = self._extractKey((properties, attProperties,
kwargs), "Mask", "")
self._format = self._extractKey((properties, attProperties,
kwargs), "Format", "")
self._validregex = self._extractKey((properties, attProperties,
kwargs), "ValidRegex", "")
@@ -87,15 +87,8 @@
preClass = wx.lib.masked.TextCtrl
tbm.dTextBoxMixin.__init__(self, preClass, parent, properties,
attProperties,
*args, **kwargs)
-
-
-
- def _getUsePlainValue(self):
- return getattr(self, "_usePlainValue", False)
-
- def _setUsePlainValue(self, val):
- self._usePlainValue = bool(val)
+
def getFormats(cls):
"""Return a list of available format codes."""
return cls._formatMap.keys()
@@ -163,6 +156,39 @@
return self.GetValue()
+ def _getUnmaskedValue(self):
+ return self.GetPlainValue()
+
+
+ def _getValue(self):
+ if self.ValueMode == "Masked":
+ ret = self.GetValue()
+ else:
+ ret = self.GetPlainValue()
+ return ret
+
+ def _setValue(self, val):
+ super(dMaskedTextBox, self)._setValue(val)
+
+
+ def _getValueMode(self):
+ try:
+ if self._valueMode.lower().startswith("m"):
+ return "Masked"
+ else:
+ return "Unmasked"
+ except (TypeError, AttributeError):
+ return "Unmasked"
+
+ def _setValueMode(self, val):
+ if self._constructed():
+ self._valueMode = val
+ else:
+ self._properties["ValueMode"] = val
+
+
+
+
# Property definitions:
Format = property(_getFormat, _setFormat, None,
_("""Several pre-defined formats are available. When
you set the Format
@@ -267,12 +293,26 @@
MaskedValue = property(_getMaskedValue, None, None,
_("Value of the control, including mask characters, if
any. (read-only) (str)"))
- UsePlainValue = property(_getUsePlainValue, _setUsePlainValue, None,
- _("Specifies whether or not to use the GetPlainValue or
GetValue. (bool)"))
-
+ UnmaskedValue = property(_getUnmaskedValue, None, None,
+ _("Value of the control, removing mask characters, if
any. (read-only) (str)"))
+
+ Value = property(_getValue, _setValue, None,
+ _("""Specifies the content of this control. (str) If
ValueMode is set to 'Masked',
+ this will include the mask characters. Otherwise it
will be the contents without
+ any mask characters."""))
+ ValueMode = property(_getValueMode, _setValueMode, None,
+ _("""Specifies the information that the Value property
refers to. (str)
+ If it is set to 'Masked' (or anything that begins with
the letter 'm'), the
+ Value property will return the contents of the control,
including any mask
+ characters. If this is set to anything other than a
string that begins with 'm',
+ Value will return the control's contents without the
mask characters.
+ NOTE: This only affects the results of *reading* the
Value property. Setting
+ Value is not affected in any way."""))
+
+
if __name__ == "__main__":
import test
Modified: trunk/dabo/ui/uiwx/test.py
===================================================================
--- trunk/dabo/ui/uiwx/test.py 2008-12-07 14:56:02 UTC (rev 4795)
+++ trunk/dabo/ui/uiwx/test.py 2008-12-07 15:34:28 UTC (rev 4796)
@@ -18,8 +18,9 @@
import traceback
import wx
import dabo
-import dabo.ui as ui
-ui.loadUI("wx")
+dabo.ui.loadUI("wx")
+# Shorthand
+ui = dabo.ui
# Log all events except the really frequent ones:
logEvents = ["All", "Idle", "MouseMove"]
@@ -91,22 +92,28 @@
modules.sort()
for modname in modules:
+ print "==> ", modname
# if the module has a test class, instantiate it:
if modname == "__init__":
# importing __init__ will pollute the dabo.ui
namespace and cause
# isinstance() problems.
continue
- mod = __import__(modname)
+ try:
+ mod = __import__(modname)
+ except ImportError, e:
+ print "ImportError:", e
+ continue
objname = "_%s_test" % modname
if mod.__dict__.has_key(objname):
print "Trying to instantiate %s..." % objname
try:
obj = mod.__dict__[objname](panel)
- except Exception, e:
+ except StandardError, e:
print
"+++++++++++++++++++++++++++++++++++++++"
print "+++ Instantiating %s caused:" %
objname
print
traceback.print_exception(*sys.exc_info())
print
"+++++++++++++++++++++++++++++++++++++++"
+ continue
if objname == "_dToolBar_test":
frame.ToolBar = obj
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev
Searchable Archives: http://leafe.com/archives/search/dabo-dev
This message: http://leafe.com/archives/byMID/[EMAIL PROTECTED]