dabo Commit
Revision 7123
Date: 2012-03-22 10:07:48 -0700 (Thu, 22 Mar 2012)
Author: Paul
Trac: http://trac.dabodev.com/changeset/7123

Changed:
U   trunk/dabo/ui/uiwx/dNumericBox.py
U   trunk/dabo/ui/uiwx/test.py

Log:
Fixed up some style in dNumericBox code and added a test with the 
DecimalWidth=0 that 
is raising the following traceback on my machine (from wxPython) when the user 
deletes
the current value and types a number:

Traceback (most recent call last):
  File 
"/usr/lib/python2.6/dist-packages/wx-2.8-gtk2-unicode/wx/lib/masked/maskededit.py",
 line 3119, in _OnChar
    newfield = self._FindField(newpos)
  File 
"/usr/lib/python2.6/dist-packages/wx-2.8-gtk2-unicode/wx/lib/masked/maskededit.py",
 line 3203, in _FindField
    raise IndexError('position %s out of range of control' % str(pos))
IndexError: position 15 out of range of control



Diff:
Modified: trunk/dabo/ui/uiwx/dNumericBox.py
===================================================================
--- trunk/dabo/ui/uiwx/dNumericBox.py   2012-03-20 21:13:01 UTC (rev 7122)
+++ trunk/dabo/ui/uiwx/dNumericBox.py   2012-03-22 17:07:48 UTC (rev 7123)
@@ -1,6 +1,5 @@
 # -*- coding: utf-8 -*-
 import locale
-import decimal
 import wx
 import wx.lib.masked as masked
 import dabo
@@ -10,6 +9,7 @@
 import dabo.dColors as dColors
 import dTextBoxMixin as dtbm
 import dDataControlMixin as ddcm
+from decimal import Decimal
 from types import NoneType
 from dabo.ui import makeDynamicProperty
 from dabo.dLocalize import _
@@ -81,7 +81,7 @@
        def getBlankValue(self):
                dec = self.DecimalWidth
                if dec > 0:
-                       return decimal.Decimal("0.%s" % ("0" * dec))
+                       return Decimal("0.%s" % ("0" * dec))
                else:
                        return 0
 
@@ -194,13 +194,13 @@
 
        def _getMinValue(self):
                val = self.GetMin()
-               if val is not None and self._lastDataType is decimal.Decimal:
-                       val = decimal.Decimal(str(val))
+               if val is not None and self._lastDataType is Decimal:
+                       val = Decimal(str(val))
                return val
 
        def _setMinValue(self, val):
                if self._constructed():
-                       if isinstance(val, decimal.Decimal):
+                       if isinstance(val, Decimal):
                                val = float(val)
                        self.SetMin(val)
                else:
@@ -208,13 +208,13 @@
 
        def _getMaxValue(self):
                val = self.GetMax()
-               if val is not None and self._lastDataType is decimal.Decimal:
-                       val = decimal.Decimal(str(val))
+               if val is not None and self._lastDataType is Decimal:
+                       val = Decimal(str(val))
                return val
 
        def _setMaxValue(self, val):
                if self._constructed():
-                       if isinstance(val, decimal.Decimal):
+                       if isinstance(val, Decimal):
                                val = float(val)
                        self.SetMax(val)
                else:
@@ -276,12 +276,12 @@
 
        def _getValue(self):
                val = ddcm.dDataControlMixin._getValue(self)
-               if self._lastDataType is decimal.Decimal:
-                       val = decimal.Decimal(str(val))
+               if self._lastDataType is Decimal:
+                       val = Decimal(str(val))
                elif self._lastDataType is NoneType:
                        chkVal = int(val)
-                       if chkVal <> val:
-                               val = decimal.Decimal(str(val))
+                       if chkVal != val:
+                               val = Decimal(str(val))
                        elif chkVal <> 0:
                                val = chkVal
                        else:
@@ -290,7 +290,7 @@
 
        def _setValue(self, val):
                self._lastDataType = type(val)
-               if self._lastDataType is decimal.Decimal:
+               if self._lastDataType is Decimal:
                        val = float(val)
                elif val is None:
                        val = float(0)
@@ -385,6 +385,13 @@
 if __name__ == "__main__":
        import test
 
-       class _dNumericBoxTest(dNumericBox): pass
+       class _testDecimal2(dNumericBox):
+               def initProperties(self):
+                       self.Value = Decimal("1.23")
+                       self.DecimalWidth = 3
 
-       test.Test().runTest(_dNumericBoxTest)
+       class _testDecimal0(dNumericBox):
+               def initProperties(self):
+                       self.Value = Decimal("23")
+                       self.DecimalWidth = 0
+       test.Test().runTest((_testDecimal2, _testDecimal0))

Modified: trunk/dabo/ui/uiwx/test.py
===================================================================
--- trunk/dabo/ui/uiwx/test.py  2012-03-20 21:13:01 UTC (rev 7122)
+++ trunk/dabo/ui/uiwx/test.py  2012-03-22 17:07:48 UTC (rev 7123)
@@ -46,7 +46,7 @@
                        frame.testObjects = []
                        for class_ in classRefs:
                                obj = class_(parent=panel, LogEvents=logEvents, 
*args, **kwargs)
-                               panel.Sizer.append(obj, 1, "expand")
+                               panel.Sizer.append(obj, "expand")
                                frame.testObjects.append(obj)
 
                        # This will get a good approximation of the required 
size



_______________________________________________
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]

Reply via email to