dabo Commit
Revision 4122
Date: 2008-06-08 09:45:28 -0700 (Sun, 08 Jun 2008)
Author: Ed
Trac: http://svn.dabodev.com/trac/dabo/changeset/4122
Changed:
U trunk/ide/ClassDesigner.py
U trunk/ide/ClassDesignerComponents.py
U trunk/ide/ClassDesignerControlMixin.py
U trunk/ide/ClassDesignerFormMixin.py
U trunk/ide/ClassDesignerPropSheet.py
Log:
Changed the idiom that uses has_key() to try/except KeyError.
Optimized the performance of the evtsForClass() method.
Added properties to labels, panels, html controls and scroll panels.
Added workaround for trailing period oddity on Mac OS X and file names.
Diff:
Modified: trunk/ide/ClassDesigner.py
===================================================================
--- trunk/ide/ClassDesigner.py 2008-06-08 16:42:01 UTC (rev 4121)
+++ trunk/ide/ClassDesigner.py 2008-06-08 16:45:28 UTC (rev 4122)
@@ -353,16 +353,13 @@
dui.dToggleButton, dui.dTreeView, dlgs.Wizard,
dlgs.WizardPage)
def evtsForClass(cls):
- ret = []
- for kk, vv in dEvents.__dict__.items():
- if kk in baseEvents:
- # These are superclasses of individual
events.
- continue
+ def safeApplies(itm, cls):
try:
- if vv.appliesToClass(cls):
- ret.append("on%s" % kk)
- except:
- pass
+ return itm.appliesToClass(cls)
+ except (AttributeError, NameError):
+ return False
+ ret = ["on%s" % k for k,v in dEvents.__dict__.items()
+ if safeApplies(v,cls)]
ret.sort()
return ret
@@ -807,6 +804,7 @@
ornt = self._extractKey(atts, "Orientation",
"h")
slots = int(self._extractKey(atts, "SlotCount",
"1"))
useBox, boxCaption = None, None
+# defSpacing = int(self._extractKey(atts,
"DefaultSpacing", "0"))
if clsname == "LayoutBorderSizer":
useBox = True
boxCaption = self._extractKey(atts,
"Caption", None)
@@ -814,7 +812,12 @@
useBox=useBox,
boxCaption=boxCaption)
szCont = sz.ControllingSizer
itm = sz.ControllingSizerItem
-
+# if defSpacing:
+# # Need to set this *after* the design
has been created, or else
+# # it will create non-Designer spacers
that will confuse things.
+# def setLater(sz, spc):
+# sz.DefaultSpacing = spc
+# dabo.ui.callAfter(setLater, sz,
defSpacing)
is2D = isinstance(szCont, dabo.ui.dGridSizer)
defaults = {True: szItemDefaults[2],
False: szItemDefaults[1]}[is2D]
@@ -2047,7 +2050,9 @@
if data["propName"]:
if adding:
prop = data["propName"]
- if not self._classPropDict.has_key(obj):
+ try:
+ self._classPropDict.["obj"]
+ except KeyError:
self._classPropDict[obj] = {}
# Make sure that there are no single quotes in
the comment
self._classPropDict[obj][prop] = data
@@ -2532,11 +2537,13 @@
# Make sure it adds customized columns.
props["ColumnClass"] = self.getControlClass(dui.dColumn)
newCols = None
- if not props.has_key("ColumnCount"):
+ try:
+ props["ColumnCount"]
+ except KeyError:
try:
newCols = int(dui.getString(_("How many
columns?"),
_("New Grid Control"),
"3"))
- except:
+ except ValueError:
newCols = 3
if useSizers:
Modified: trunk/ide/ClassDesignerComponents.py
===================================================================
--- trunk/ide/ClassDesignerComponents.py 2008-06-08 16:42:01 UTC (rev
4121)
+++ trunk/ide/ClassDesignerComponents.py 2008-06-08 16:45:28 UTC (rev
4122)
@@ -177,25 +177,28 @@
# If it hasn't changed from the default, skip it
if not allProps:
- if defVals.has_key(prop):
- if prop not in propsToInclude:
- dv = defVals[prop]
- if not isinstance(val,
basestring) and isinstance(dv, basestring):
- # Try to convert
- if isinstance(val,
bool):
- dv =
(dv.lower() == "true")
- elif isinstance(val,
int):
- dv = int(dv)
- elif isinstance(val,
long):
- dv = long(dv)
- elif isinstance(val,
float):
- dv = float(dv)
- elif isinstance(val,
(list, tuple, dict)):
- dv = eval(dv)
- elif dv == "None":
- dv = None
- if dv == val:
- continue
+ try:
+ defVals[prop]
+ except KeyError:
+ continue
+ if prop not in propsToInclude:
+ dv = defVals[prop]
+ if not isinstance(val, basestring) and
isinstance(dv, basestring):
+ # Try to convert
+ if isinstance(val, bool):
+ dv = (dv.lower() ==
"true")
+ elif isinstance(val, int):
+ dv = int(dv)
+ elif isinstance(val, long):
+ dv = long(dv)
+ elif isinstance(val, float):
+ dv = float(dv)
+ elif isinstance(val, (list,
tuple, dict)):
+ dv = eval(dv)
+ elif dv == "None":
+ dv = None
+ if dv == val:
+ continue
if isinstance(val, basestring):
strval = val
Modified: trunk/ide/ClassDesignerControlMixin.py
===================================================================
--- trunk/ide/ClassDesignerControlMixin.py 2008-06-08 16:42:01 UTC (rev
4121)
+++ trunk/ide/ClassDesignerControlMixin.py 2008-06-08 16:45:28 UTC (rev
4122)
@@ -745,11 +745,14 @@
"ShowRowLabels" : {"type" : bool, "readonly" :
False}}
imageProps = {"ScaleMode" : {"type" : list, "readonly" : False,
"values" : ["Clip", "Proportional",
"Stretch"]}}
+ labelProps = {"AutoResize": {"type" : bool, "readonly" : False}}
multiSelectProps = {"MultipleSelect": {"type" : bool,
"readonly" : False}}
nodeProps = {"Image": {"type" : "path", "readonly" : False,
"customEditor": "editStdPicture"}}
- panelProps = {"Buffered" : {"type" : bool, "readonly" : False},
- "AlwaysResetSizer": {"type" : bool, "readonly"
: False}}
+ panelProps = {"AlwaysResetSizer": {"type" : bool, "readonly" :
False},
+ "Buffered" : {"type" : bool, "readonly" :
False},
+ "MinSizerHeight": {"type" : int, "readonly" :
False},
+ "MinSizerWidth": {"type" : int, "readonly" :
False}}
pictureProps = {"Picture": {"type" : "path", "readonly" :
False,
"customEditor": "editStdPicture"}}
posProps = {"Left": {"type" : int, "readonly" : useSizers},
@@ -791,10 +794,11 @@
"ForceCase": {"type" : list, "readonly" : False,
"values" : ["Upper", "Lower", "Title",
"None"]},
"ReadOnly" : {"type" : bool, "readonly" :
False}}
- htmlTextProps = {"HorizontalScroll": {"type" : bool, "readonly"
: False},
- "Page": {"type" : unicode, "readonly" : False},
+ htmlTextProps = {"Page": {"type" : unicode, "readonly" : False},
"RespondToLinks": {"type" : bool, "readonly" :
False},
"ShowScrollBars": {"type" : bool, "readonly" :
False},
+ "Source": {"type" : unicode, "readonly" :
False}}
+ scrollProps = {"HorizontalScroll": {"type" : bool, "readonly" :
False},
"VerticalScroll": {"type" : bool, "readonly" :
False}}
treeProps = {"Editable" : {"type" : bool, "readonly" : False},
"MultipleSelect" : {"type" : bool, "readonly" :
False},
@@ -882,6 +886,7 @@
ret.update(pictureProps)
ret.update(imageProps)
elif isinstance(self, dabo.ui.dLabel):
+ ret.update(labelProps)
ret.update(colorProps)
ret.update(captionProps)
ret.update(fontProps)
@@ -941,6 +946,7 @@
ret.update(wizardPageProps)
elif isinstance(self, dabo.ui.dScrollPanel):
ret.update(panelProps)
+ ret.update(scrollProps)
ret.update(colorProps)
elif isinstance(self, dabo.ui.dPanel):
ret.update(panelProps)
@@ -966,6 +972,7 @@
"TextLength" : {"type" : int,
"readonly" : False}})
elif isinstance(self, dabo.ui.dHtmlBox):
ret.update(htmlTextProps)
+ ret.update(scrollProps)
elif isinstance(self, dabo.ui.dTimer):
pass
elif isinstance(self, dabo.ui.dToggleButton):
Modified: trunk/ide/ClassDesignerFormMixin.py
===================================================================
--- trunk/ide/ClassDesignerFormMixin.py 2008-06-08 16:42:01 UTC (rev 4121)
+++ trunk/ide/ClassDesignerFormMixin.py 2008-06-08 16:45:28 UTC (rev 4122)
@@ -448,7 +448,8 @@
# User canceled
return
else:
- if not
os.path.splitext(self._classFile)[1] == ".cdxml":
+ self._classFile =
self._classFile.rstrip(".")
+ if not
self._classFile.endswith(".cdxml"):
self._classFile += ".cdxml"
fname = self._classFile
@@ -483,9 +484,13 @@
# Try opening the file. If it is read-only, it will raise an
# IOErrorrror that the calling method can catch.
open(fname, "wb").write(xml)
- if not singleFile:
- # Now write out the code file
- cfName = "%s-code.py" % os.path.splitext(fname)[0]
+ cfName = "%s-code.py" % os.path.splitext(fname)[0]
+ if singleFile:
+ # Delete the code file if present.
+ if os.path.exists(cfName):
+ os.remove(cfName)
+ else:
+ # Write out the code file
open(cfName,
"wb").write(self._createDesignerCode(codeDict))
if currForm:
currForm.bringToFront()
@@ -1001,14 +1006,16 @@
def hideHandles(self, ctl=None, release=False):
if ctl is None:
return
- if self.handles.has_key(ctl):
+ try:
hnd = self.handles[ctl]
- for nm,h in hnd.items():
- h.Visible = False
- if release:
- h.release()
+ except KeyError:
+ return
+ for nm,h in hnd.items():
+ h.Visible = False
if release:
- del self.handles[ctl]
+ h.release()
+ if release:
+ del self.handles[ctl]
def alignControls(self, evt, edge):
Modified: trunk/ide/ClassDesignerPropSheet.py
===================================================================
--- trunk/ide/ClassDesignerPropSheet.py 2008-06-08 16:42:01 UTC (rev 4121)
+++ trunk/ide/ClassDesignerPropSheet.py 2008-06-08 16:45:28 UTC (rev 4122)
@@ -318,7 +318,7 @@
except PropertyUpdateException, e:
dabo.ui.stop(_("Could not set property '%s' to value
'%s'\nReason: '%s'")
% (prop, val, e))
- self.updateGridValues()
+ self.updateGridValues()
def updateGridValues(self):
_______________________________________________
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]