dabo Commit
Revision 5918
Date: 2010-07-10 10:14:21 -0700 (Sat, 10 Jul 2010)
Author: Ed
Trac: http://trac.dabodev.com/changeset/5918

Changed:
U   trunk/dabo/ui/uiwx/__init__.py
U   trunk/dabo/ui/uiwx/alignmentMixin.py
U   trunk/dabo/ui/uiwx/concordance.py
U   trunk/dabo/ui/uiwx/dControlItemMixin.py
U   trunk/dabo/ui/uiwx/dDataControlMixin.py
U   trunk/dabo/ui/uiwx/dFont.py
U   trunk/dabo/ui/uiwx/dForm.py
U   trunk/dabo/ui/uiwx/dFormMixin.py
U   trunk/dabo/ui/uiwx/dGrid.py
U   trunk/dabo/ui/uiwx/dLine.py

Log:
Converted more of the codebase from str() to ustr().

Added some sizer outline improvements to dFormMixin.


Diff:
Modified: trunk/dabo/ui/uiwx/__init__.py
===================================================================
--- trunk/dabo/ui/uiwx/__init__.py      2010-07-10 16:51:15 UTC (rev 5917)
+++ trunk/dabo/ui/uiwx/__init__.py      2010-07-10 17:14:21 UTC (rev 5918)
@@ -9,6 +9,7 @@
 import cStringIO
 import warnings
 from dabo.dLocalize import _
+from dabo.lib.utils import ustr
 from dabo.lib import utils
 import dabo.dEvents as dEvents
 
@@ -362,7 +363,7 @@
                        pass
                else:
                        dabo.errorLog.write("Incorrect event class (%s) passed 
to continueEvent. Error: %s"
-                                       % (str(evt), str(e)))
+                                       % (ustr(evt), ustr(e)))
 
 
 def discontinueEvent(evt):
@@ -374,7 +375,7 @@
                        pass
                else:
                        dabo.errorLog.write("Incorrect event class (%s) passed 
to continueEvent. Error: %s"
-                                       % (str(evt), str(e)))
+                                       % (ustr(evt), ustr(e)))
 
 
 def getEventData(wxEvt):
@@ -1121,7 +1122,7 @@
                key = itm
                if not isinstance(itm, basestring):
                        needConvert = True
-                       key = str(itm)
+                       key = ustr(itm)
                        strChc.append(key)
                else:
                        strChc.append(itm)

Modified: trunk/dabo/ui/uiwx/alignmentMixin.py
===================================================================
--- trunk/dabo/ui/uiwx/alignmentMixin.py        2010-07-10 16:51:15 UTC (rev 
5917)
+++ trunk/dabo/ui/uiwx/alignmentMixin.py        2010-07-10 17:14:21 UTC (rev 
5918)
@@ -1,6 +1,7 @@
 # -*- coding: utf-8 -*-
 import wx
 from dabo.dLocalize import _
+from dabo.lib.utils import ustr
 from dabo.ui import makeDynamicProperty
 
 class AlignmentMixin(object):
@@ -17,7 +18,7 @@
                self._delWindowStyleFlag(wx.ALIGN_LEFT)
                self._delWindowStyleFlag(wx.ALIGN_CENTRE)
                self._delWindowStyleFlag(wx.ALIGN_RIGHT)
-               value = str(value).lower()
+               value = ustr(value).lower()
 
                if value == "left":
                        self._addWindowStyleFlag(wx.ALIGN_LEFT)

Modified: trunk/dabo/ui/uiwx/concordance.py
===================================================================
--- trunk/dabo/ui/uiwx/concordance.py   2010-07-10 16:51:15 UTC (rev 5917)
+++ trunk/dabo/ui/uiwx/concordance.py   2010-07-10 17:14:21 UTC (rev 5918)
@@ -1,6 +1,7 @@
 # -*- coding: utf-8 -*-
 import wx
 import dabo
+from dabo.lib.utils import ustr
 
 dabo.ui.loadUI("wx")
 
@@ -13,13 +14,13 @@
        daboClass = getattr(dabo.ui, daboName)
        if hasattr(daboClass, "__mro__"):
                for mro in daboClass.__mro__:
-                       if "<class 'wx." in str(mro):
-                               if "wx._" in str(mro):
+                       if "<class 'wx." in ustr(mro):
+                               if "wx._" in ustr(mro):
                                        # normal wx class: don't include the 
wx._controls. cruft
-                                       dabo_to_wx[daboName] = "wx.%s" % 
str(mro).split(".")[-1][:-2]
+                                       dabo_to_wx[daboName] = "wx.%s" % 
ustr(mro).split(".")[-1][:-2]
                                else:
                                        # extra class: give the full story:
-                                       dabo_to_wx[daboName] = str(mro)[8:-2] 
+                                       dabo_to_wx[daboName] = ustr(mro)[8:-2] 
                                break
 
 daboNames = dabo_to_wx.items()

Modified: trunk/dabo/ui/uiwx/dControlItemMixin.py
===================================================================
--- trunk/dabo/ui/uiwx/dControlItemMixin.py     2010-07-10 16:51:15 UTC (rev 
5917)
+++ trunk/dabo/ui/uiwx/dControlItemMixin.py     2010-07-10 17:14:21 UTC (rev 
5918)
@@ -4,6 +4,7 @@
 import dabo.dEvents as dEvents
 from dDataControlMixin import dDataControlMixin
 from dabo.dLocalize import _
+from dabo.lib.utils import ustr
 from dabo.ui import makeDynamicProperty
 
 
@@ -392,7 +393,7 @@
                
                
        def _setValueMode(self, val):
-               val = str(val).lower()[0]
+               val = ustr(val).lower()[0]
                if val in ("p", "s", "k"):
                        self._valueMode = val
                        

Modified: trunk/dabo/ui/uiwx/dDataControlMixin.py
===================================================================
--- trunk/dabo/ui/uiwx/dDataControlMixin.py     2010-07-10 16:51:15 UTC (rev 
5917)
+++ trunk/dabo/ui/uiwx/dDataControlMixin.py     2010-07-10 17:14:21 UTC (rev 
5918)
@@ -2,9 +2,11 @@
 import dabo
 from dabo.ui.dDataControlMixinBase import dDataControlMixinBase
 from dabo.dLocalize import _
+from dabo.lib.utils import ustr
 from dabo.ui import makeDynamicProperty
 
 
+
 class dDataControlMixin(dDataControlMixinBase):
        def _onWxHit(self, evt, *args, **kwargs):
                self._userChanged = True  ## set the dirty flag so that 
InteractiveChange can be raised.
@@ -45,7 +47,7 @@
                oldType = type(oldval)
                if isinstance(val, convTypes) and isinstance(oldval, 
basestring):
                        if isinstance(oldType, str):
-                               val = str(val)
+                               val = ustr(val)
                        else:
                                if not isinstance(val, unicode):
                                        val = unicode(val, 
self.Application.Encoding)

Modified: trunk/dabo/ui/uiwx/dFont.py
===================================================================
--- trunk/dabo/ui/uiwx/dFont.py 2010-07-10 16:51:15 UTC (rev 5917)
+++ trunk/dabo/ui/uiwx/dFont.py 2010-07-10 17:14:21 UTC (rev 5918)
@@ -3,9 +3,11 @@
 import dabo
 from dabo.dObject import dObject
 from dabo.dLocalize import _
+from dabo.lib.utils import ustr
 from dabo.ui import makeDynamicProperty
 
 
+
 class dFont(dObject):
        """This class wraps the various font properties into a single object."""
        def __init__(self, properties=None, _nativeFont=None, *args, **kwargs):
@@ -38,7 +40,7 @@
 
 
        def _getDescription(self):
-               ret = self.Face + " " + str(self.Size)
+               ret = self.Face + " " + ustr(self.Size)
                if self.Bold:
                        ret += " B"
                if self.Italic:

Modified: trunk/dabo/ui/uiwx/dForm.py
===================================================================
--- trunk/dabo/ui/uiwx/dForm.py 2010-07-10 16:51:15 UTC (rev 5917)
+++ trunk/dabo/ui/uiwx/dForm.py 2010-07-10 17:14:21 UTC (rev 5918)
@@ -9,6 +9,7 @@
 import dFormMixin as fm
 import dabo.dException as dException
 from dabo.dLocalize import _
+from dabo.lib.utils import ustr
 from dabo.ui import makeDynamicProperty
 from dDialog import dDialog
 
@@ -254,7 +255,7 @@
                        
self.setStatusText(self.getCurrentRecordText(dataSource) + " (EOF)")
                        return False
                except dException.dException, e:
-                       self.notifyUser(str(e), exception=e)
+                       self.notifyUser(ustr(e), exception=e)
                        return False
                else:
                        if biz.RowNumber != oldRowNum:
@@ -389,7 +390,7 @@
                                        self.SaveAllRows and "all records" or 
"current record",))
                                        
                except dException.ConnectionLostException, e:
-                       msg = self._connectionLostMsg(str(e))
+                       msg = self._connectionLostMsg(ustr(e))
                        self.notifyUser(msg, title=_("Data Connection Lost"), 
severe=True, exception=e)
                        sys.exit()
 
@@ -446,7 +447,7 @@
                        dabo.errorLog.write(_("Cancel failed; no records to 
cancel."))
                except dException.dException, e:
                        dabo.errorLog.write(_("Cancel failed with response: 
%s") % e)
-                       self.notifyUser(str(e), title=_("Cancel Not Allowed"), 
exception=e)
+                       self.notifyUser(ustr(e), title=_("Cancel Not Allowed"), 
exception=e)
                self.afterCancel()
                self.refresh()
 
@@ -505,23 +506,23 @@
                                        _("%(rc)s record%(plcnt)sselected in 
%(elapsed)s second%(plelap)s") % locals())
 
                except dException.MissingPKException, e:
-                       self.notifyUser(str(e), title=_("Requery Failed"), 
severe=True, exception=e)
+                       self.notifyUser(ustr(e), title=_("Requery Failed"), 
severe=True, exception=e)
                        self.StatusText = ""
 
                except dException.ConnectionLostException, e:
-                       msg = self._connectionLostMsg(str(e))
+                       msg = self._connectionLostMsg(ustr(e))
                        self.notifyUser(msg, title=_("Data Connection Lost"), 
severe=True, exception=e)
                        self.StatusText = ""
                        sys.exit()
 
                except dException.DBQueryException, e:
                        dabo.errorLog.write(_("Database Execution failed with 
response: %s") % e)
-                       self.notifyUser(str(e), title=_("Database Action 
Failed"), severe=True, exception=e)
+                       self.notifyUser(ustr(e), title=_("Database Action 
Failed"), severe=True, exception=e)
                        self.StatusText = ""
 
                except dException.dException, e:
                        dabo.errorLog.write(_("Requery failed with response: 
%s") % e)
-                       self.notifyUser(str(e), title=_("Requery Not Allowed"), 
severe=True, exception=e)
+                       self.notifyUser(ustr(e), title=_("Requery Not 
Allowed"), severe=True, exception=e)
                        self.StatusText = ""
 
                self.afterRequery()
@@ -564,12 +565,12 @@
                                # Notify listeners that the row number changed:
                                self.raiseEvent(dEvents.RowNumChanged)
                        except dException.ConnectionLostException, e:
-                               msg = self._connectionLostMsg(str(e))
+                               msg = self._connectionLostMsg(ustr(e))
                                self.notifyUser(msg, title=_("Data Connection 
Lost"), severe=True, exception=e)
                                sys.exit()
                        except dException.dException, e:
                                dabo.errorLog.write(_("Delete failed with 
response: %s") % e)
-                               self.notifyUser(str(e), title=_("Deletion Not 
Allowed"), severe=True, exception=e)
+                               self.notifyUser(ustr(e), title=_("Deletion Not 
Allowed"), severe=True, exception=e)
                        self.afterDelete()
                self.update()
                self.refresh()
@@ -598,12 +599,12 @@
                                # Notify listeners that the row number changed:
                                self.raiseEvent(dEvents.RowNumChanged)
                        except dException.ConnectionLostException, e:
-                               msg = self._connectionLostMsg(str(e))
+                               msg = self._connectionLostMsg(ustr(e))
                                self.notifyUser(msg, title=_("Data Connection 
Lost"), severe=True, exception=e)
                                sys.exit()
                        except dException.dException, e:
                                dabo.errorLog.write(_("Delete All failed with 
response: %s") % e)
-                               self.notifyUser(str(e), title=_("Deletion Not 
Allowed"), severe=True, exception=e)
+                               self.notifyUser(ustr(e), title=_("Deletion Not 
Allowed"), severe=True, exception=e)
                self.afterDeleteAll()
                self.update()
                self.refresh()

Modified: trunk/dabo/ui/uiwx/dFormMixin.py
===================================================================
--- trunk/dabo/ui/uiwx/dFormMixin.py    2010-07-10 16:51:15 UTC (rev 5917)
+++ trunk/dabo/ui/uiwx/dFormMixin.py    2010-07-10 17:14:21 UTC (rev 5918)
@@ -7,6 +7,7 @@
 import dMenu
 import dabo.icons
 from dabo.dLocalize import _
+from dabo.lib.utils import ustr
 import dabo.dEvents as dEvents
 import dabo.dException as dException
 from dabo.lib.xmltodict import xmltodict as XTD
@@ -20,6 +21,10 @@
                self._cxnName = ""
                self._connection = None
                self._floatingPanel = None
+               self._sizersToOutline = []
+               self._recurseOutlinedSizers = True
+               self._alwaysDrawSizerOutlines = False
+               self._drawSizerChildren = False
                self._statusBarClass = dabo.ui.dStatusBar
                
                # Extract the menu definition file, if any
@@ -208,9 +213,10 @@
        
        
        def __onIdle(self, evt):
-               if self.__needOutlineRedraw:
-                       if self.Sizer:
-                               self.Sizer.drawOutline(self, recurse=True)
+               if self.__needOutlineRedraw or self._alwaysDrawSizerOutlines:
+                       for sz in self.SizersToOutline:
+                               sz.drawOutline(self, 
recurse=self._recurseOutlinedSizers,
+                                               
drawChildren=self._drawSizerChildren)
        
        
        def __onClose(self, evt):
@@ -294,8 +300,20 @@
                code that the user can later enhance.
                """
                pass
-       
-       
+
+
+       def addToOutlinedSizers(self, val):
+               self._sizersToOutline.append(val)
+
+
+       def removeFromOutlinedSizers(self, val):
+               try:
+                       self._sizersToOutline.remove(val)
+               except ValueError:
+                       # already removed
+                       pass
+
+
        def _restoreMenuPrefs(self):
                if not self:
                        # Form has already been released
@@ -893,8 +911,21 @@
                
        def _setShowToolBar(self, val):
                self._showToolBar = bool(val)   
-       
 
+
+       def _getSizersToOutline(self):
+               if self._alwaysDrawSizerOutlines:
+                       return self._sizersToOutline
+               else:
+                       ret = self._sizersToOutline or self.Sizer
+                       if not isinstance(ret, list):
+                               ret = [ret]
+                       return ret
+
+       def _setSizersToOutline(self, val):
+               self._sizersToOutline = val
+
+
        def _getStatusBar(self):
                try:
                        return self.GetStatusBar()
@@ -1013,7 +1044,7 @@
 
        def _setWindowState(self, value):
                if self._constructed():
-                       lowvalue = str(value).lower().strip()
+                       lowvalue = ustr(value).lower().strip()
                        if lowvalue == "normal":
                                if self.IsFullScreen():
                                        self.ShowFullScreen(False)
@@ -1126,6 +1157,10 @@
        ShowToolBar = property(_getShowToolBar, _setShowToolBar, None,
                        _("Specifies whether the Tool bar gets automatically 
created."))
 
+       SizersToOutline = property(_getSizersToOutline, _setSizersToOutline, 
None,
+                       _("""When drawing the outline of sizers, the sizer(s) 
to draw. 
+                       Default=self.Sizer  (dSizer)"""))
+
        StatusBar = property(_getStatusBar, _setStatusBar, None,
                        _("Status bar for this form. (dStatusBar)"))
 

Modified: trunk/dabo/ui/uiwx/dGrid.py
===================================================================
--- trunk/dabo/ui/uiwx/dGrid.py 2010-07-10 16:51:15 UTC (rev 5917)
+++ trunk/dabo/ui/uiwx/dGrid.py 2010-07-10 17:14:21 UTC (rev 5918)
@@ -17,6 +17,7 @@
 import dabo.dEvents as dEvents
 import dabo.dException as dException
 from dabo.dLocalize import _, n_
+from dabo.lib.utils import ustr
 import dControlMixin as cm
 import dKeys
 import dUICursors
@@ -117,7 +118,7 @@
                for idx, col in enumerate(colDefs):
                        nm = col.DataField
                        while not nm:
-                               nm = str(idx)
+                               nm = ustr(idx)
                                idx += 1
                                if nm in colDefs:
                                        nm = ""
@@ -146,12 +147,12 @@
                                        # Not one of the standard types. 
Extract it from
                                        # the string version of the type
                                        try:
-                                               col.DataType = 
str(col.DataType).split("'")[1].lower()
+                                               col.DataType = 
ustr(col.DataType).split("'")[1].lower()
                                        except IndexError:
                                                # Something's odd. Print an 
error message and move on.
                                                dabo.errorLog.write("Unknown 
data type found in setColumns(): %s"
                                                                % col.DataType)
-                                               col.DataType = str(col.DataType)
+                                               col.DataType = 
ustr(col.DataType)
 
                # Make sure that all cols have an Order set
                for num in range(len(colDefs)):
@@ -349,15 +350,15 @@
 class GridListEditor(wx.grid.GridCellChoiceEditor):
        def __init__(self, *args, **kwargs):
                dabo.infoLog.write("GridListEditor: Init ")
-               dabo.infoLog.write(str(args))
-               dabo.infoLog.write(str(kwargs))
+               dabo.infoLog.write(ustr(args))
+               dabo.infoLog.write(ustr(kwargs))
                super(GridListEditor, self).__init__(*args, **kwargs)
 
 
        def Create(self, parent, id, evtHandler, *args, **kwargs):
                dabo.infoLog.write("GridListEditor: Create")
-               dabo.infoLog.write(str(args))
-               dabo.infoLog.write(str(kwargs))
+               dabo.infoLog.write(ustr(args))
+               dabo.infoLog.write(ustr(kwargs))
                self.control = dabo.ui.dDropdownList(parent=parent, id=id,
                                ValueMode="String")
                self.SetControl(self.control)
@@ -1984,7 +1985,7 @@
                        fld = column.DataField
                        biz = self.getBizobj()
                        if isinstance(val, float) and column.DataType == 
"decimal":
-                                val = Decimal(str(val))
+                                val = Decimal(ustr(val))
                        if biz:
                                biz.RowNumber = row
                                biz.setFieldVal(fld, val)
@@ -2874,7 +2875,7 @@
                                        srchVal = float(0)
                        elif isinstance(listval, (datetime.datetime, 
datetime.date, datetime.time)):
                                # We need to convert the sort vals into strings
-                               sortList = [(str(vv), i) for vv, i in sortList]
+                               sortList = [(ustr(vv), i) for vv, i in sortList]
                                compString = True
 
                # Now iterate through the list to find the matching value. I 
know that
@@ -2968,27 +2969,27 @@
                                srch = r"\b%s\b" % findString
                                findGen = ((r,c) for r in xrange(self.RowCount) 
for c in xrange(self.ColumnCount)
                                                if op((r,c), rowcol)
-                                               and re.search(srch, 
str(self.GetValue(r, c))))
+                                               and re.search(srch, 
ustr(self.GetValue(r, c))))
                        else:
                                srch = r"\b%s\b" % findString.lower()
                                findGen = ((r,c) for r in xrange(self.RowCount) 
for c in xrange(self.ColumnCount)
                                                if op((r,c), rowcol)
-                                               and re.search(srch, 
str(self.GetValue(r, c)).lower()))
+                                               and re.search(srch, 
ustr(self.GetValue(r, c)).lower()))
                else:
                        if matchCase:
                                findGen = ((r,c) for r in xrange(self.RowCount) 
for c in xrange(self.ColumnCount)
                                                if op((r,c), rowcol)
-                                               and findString in 
str(self.GetValue(r, c)))
+                                               and findString in 
ustr(self.GetValue(r, c)))
                        else:
                                findGen = ((r,c) for r in xrange(self.RowCount) 
for c in xrange(self.ColumnCount)
                                                if op((r,c), rowcol)
-                                               and findString.lower() in 
str(self.GetValue(r, c)).lower())
+                                               and findString.lower() in 
ustr(self.GetValue(r, c)).lower())
                if action == "Find":
                        try:
                                while True:
                                        newR, newC = findGen.next()
                                        targetVal = self.GetValue(newR, newC)
-                                       targetString = str(targetVal)
+                                       targetString = ustr(targetVal)
                                        if isinstance(targetVal, (basestring, 
datetime.datetime, datetime.date)):
                                                # Values can be inexact matches
                                                break

Modified: trunk/dabo/ui/uiwx/dLine.py
===================================================================
--- trunk/dabo/ui/uiwx/dLine.py 2010-07-10 16:51:15 UTC (rev 5917)
+++ trunk/dabo/ui/uiwx/dLine.py 2010-07-10 17:14:21 UTC (rev 5918)
@@ -6,8 +6,10 @@
 
 import dControlMixin as cm
 from dabo.ui import makeDynamicProperty
+from dabo.lib.utils import ustr
 
 
+
 class dLine(cm.dControlMixin, wx.StaticLine):
        """Creates a horizontal or vertical line.
 
@@ -40,7 +42,7 @@
                self._delWindowStyleFlag(wx.LI_VERTICAL)
                self._delWindowStyleFlag(wx.LI_HORIZONTAL)
 
-               value = str(value)
+               value = ustr(value)
 
                if value == "Vertical":
                        self._addWindowStyleFlag(wx.LI_VERTICAL)



_______________________________________________
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