dabo Commit
Revision 4132
Date: 2008-06-14 08:30:34 -0700 (Sat, 14 Jun 2008)
Author: Ed
Trac: http://svn.dabodev.com/trac/dabo/changeset/4132
Changed:
U branches/ed-ide/components/ClassDesigner/ClassDesigner.py
U branches/ed-ide/components/ClassDesigner/ClassDesignerComponents.py
U branches/ed-ide/components/ClassDesigner/ClassDesignerControlMixin.py
U branches/ed-ide/components/ClassDesigner/ClassDesignerFormMixin.py
U branches/ed-ide/components/ClassDesigner/ClassDesignerPropSheet.py
Log:
Incorporated changes from the trunk into this branch
Diff:
Modified: branches/ed-ide/components/ClassDesigner/ClassDesigner.py
===================================================================
--- branches/ed-ide/components/ClassDesigner/ClassDesigner.py 2008-06-14
15:10:46 UTC (rev 4131)
+++ branches/ed-ide/components/ClassDesigner/ClassDesigner.py 2008-06-14
15:30:34 UTC (rev 4132)
@@ -138,6 +138,7 @@
{"name" : "DateTextBox", "class" :
dui.dDateTextBox, "order" : 60},
{"name" : "DropdownList", "class" :
dui.dDropdownList, "order" : 70},
{"name" : "EditBox", "class" : dui.dEditBox,
"order" : 80},
+ {"name" : "HtmlBox", "class" : dui.dHtmlBox,
"order" : 85},
{"name" : "Gauge", "class" : dui.dGauge,
"order" : 90},
{"name" : "Grid", "class" : dui.dGrid, "order"
: 100},
{"name" : "Image", "class" : dui.dImage,
"order" : 110},
@@ -343,26 +344,22 @@
baseEvents = ("DataEvent", "EditorEvent", "GridEvent",
"KeyEvent",
"ListEvent", "MenuEvent", "MouseEvent",
"SashEvent",
"CalendarEvent", "TreeEvent")
- classes = (dui.dBox, dui.dBitmap, dui.dBitmapButton,
dui.dButton, dui.dCheckBox,
- dui.dComboBox, dui.dDateTextBox, dui.dDialog,
dui.dDropdownList,
- dui.dEditBox, dui.dEditor, dui.dForm,
dui.dDockForm, dui.dGauge, dui.dGrid, dui.dImage,
- dui.dLabel, dui.dLine, dui.dListBox,
dui.dListControl, dui.dOkCancelDialog,
- dui.dPanel, dui.dPage, dui.dScrollPanel,
dui.dPage, dui.dPageFrame,
- dui.dPageList, dui.dPageSelect,
dui.dPageFrameNoTabs, dui.dRadioList,
- dui.dSlider, dui.dSpinner, dui.dSplitter,
dui.dTextBox, dui.dToggleButton,
- dui.dTreeView, dlgs.Wizard, dlgs.WizardPage)
+ classes = (dui.dBox, dui.dBitmap, dui.dBitmapButton,
dui.dButton, dui.dCheckBox,
+ dui.dComboBox, dui.dDateTextBox, dui.dDialog,
dui.dDropdownList, dui.dEditBox,
+ dui.dEditor, dui.dForm, dui.dDockForm,
dui.dGauge, dui.dGrid, dui.dHtmlBox, dui.dImage,
+ dui.dLabel, dui.dLine, dui.dListBox,
dui.dListControl, dui.dOkCancelDialog, dui.dPanel,
+ dui.dPage, dui.dScrollPanel, dui.dPage,
dui.dPageFrame, dui.dPageList, dui.dPageSelect,
+ dui.dPageFrameNoTabs, dui.dRadioList,
dui.dSlider, dui.dSpinner, dui.dSplitter, dui.dTextBox,
+ 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]
@@ -1710,7 +1713,7 @@
"Wizard", "WizardPage",
"PageFrame", "PageList", "PageSelect",
"PageNoTabs", "Box", "Bitmap",
"BitmapButton", "Button", "CheckBox",
"ComboBox", "DateTextBox",
"DropdownList", "EditBox", "Editor",
- "Gauge", "Grid", "Image",
"Label", "Line", "ListBox", "ListControl", "Page",
+ "Gauge", "Grid", "HtmlBox",
"Image", "Label", "Line", "ListBox", "ListControl", "Page",
"RadioList", "Slider",
"Spinner", "Splitter", "TextBox", "ToggleButton",
"TreeView"]
keys = [dui.dForm, dui.dDockForm, dui.dPanel,
dui.dScrollPanel, dui.dDialog,
@@ -1718,7 +1721,7 @@
dui.dPageFrame, dui.dPageList,
dui.dPageSelect, dui.dPageFrameNoTabs,
dui.dBox, dui.dBitmap,
dui.dBitmapButton, dui.dButton, dui.dCheckBox,
dui.dComboBox,
dui.dDateTextBox, dui.dDropdownList, dui.dEditBox,
- dui.dEditor, dui.dGauge,
dui.dGrid, dui.dImage, dui.dLabel, dui.dLine,
+ dui.dEditor, dui.dGauge,
dui.dGrid, dui.dHtmlBox, dui.dImage, dui.dLabel, dui.dLine,
dui.dListBox, dui.dListControl,
dui.dPage, dui.dRadioList, dui.dSlider,
dui.dSpinner, dui.dSplitter,
dui.dTextBox, dui.dToggleButton,
dui.dTreeView]
@@ -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:
@@ -2873,6 +2880,7 @@
pop.append(_("Add DropdownList"),
OnHit=self.onNewDropdownList)
pop.append(_("Add EditBox"), OnHit=self.onNewEditBox)
pop.append(_("Add Grid"), OnHit=self.onNewGrid)
+ pop.append(_("Add HtmlBox"), OnHit=self.onNewHtmlBox)
pop.append(_("Add ListBox"), OnHit=self.onNewListBox)
pop.append(_("Add ListControl"),
OnHit=self.onNewListControl)
pop.append(_("Add RadioList"),
OnHit=self.onNewRadioList)
@@ -3086,6 +3094,8 @@
dui.callAfter(self.addNewControl, None, dui.dGauge)
def onNewGrid(self, evt):
dui.callAfter(self.addNewControl, None, dui.dGrid)
+ def onNewHtmlBox(self, evt):
+ dui.callAfter(self.addNewControl, None, dui.dHtmlBox)
def onNewImage(self, evt):
dui.callAfter(self.addNewControl, None, dui.dImage)
def onNewLabel(self, evt):
@@ -3868,6 +3878,7 @@
(_("EditBox"), dui.dEditBox),
(_("Gauge"), dui.dGauge),
(_("Grid"), dui.dGrid),
+ (_("HtmlBox"), dui.dHtmlBox),
(_("Image"), dui.dImage),
(_("Label"), dui.dLabel),
(_("Line"), dui.dLine),
Modified: branches/ed-ide/components/ClassDesigner/ClassDesignerComponents.py
===================================================================
--- branches/ed-ide/components/ClassDesigner/ClassDesignerComponents.py
2008-06-14 15:10:46 UTC (rev 4131)
+++ branches/ed-ide/components/ClassDesigner/ClassDesignerComponents.py
2008-06-14 15:30:34 UTC (rev 4132)
@@ -60,17 +60,17 @@
if insideClass:
try:
myID = self.classID.split("-")[1]
- except:
+ except IndexError:
myID = abs(self.__hash__())
if classID is None:
# First-time save. Get the classID of
the parent
try:
classID =
self.Parent.classID.split("-")[0]
- except:
+ except IndexError:
# Try the sizer
try:
classID =
self.ControllingSizer.classID.split("-")[0]
- except:
+ except IndexError:
classID =
"?????"
ra["classID"] = "%s-%s" % (classID, myID)
self.classID = ra["classID"]
@@ -106,8 +106,7 @@
else:
ra["designerClass"] = self.getClassName()
-# hasSizer = not isClass and (hasattr(self,
"ControllingSizerItem") and self.ControllingSizerItem)
- hasSizer = (hasattr(self, "ControllingSizerItem") and
self.ControllingSizerItem)
+ hasSizer = bool(hasattr(self, "ControllingSizerItem") and
self.ControllingSizerItem)
# We want to include some props whether they are the
# default or not.
if insideClass:
@@ -178,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
@@ -207,14 +209,9 @@
try:
itmProps =
self.ControllingSizer.getItemProps(self.ControllingSizerItem)
if insideClass:
- itmDiffProps =
self._diffSizerItemProps(itmProps, classDict)
+ itmDiffProps =
self._diffSizerItemProps(itmProps, classDict, direct=True)
else:
itmDiffProps =
self._diffSizerItemProps(itmProps, self.ControllingSizer)
-# try:
-# defProps =
self.Controller.getDefaultSizerProps(self.superControl)
-# itmDiffProps =
self._diffSizerItemProps(itmProps, defProps, direct=True)
-# except:
-# itmDiffProps =
self._diffSizerItemProps(itmProps, self.ControllingSizer)
ret["attributes"]["sizerInfo"] = itmDiffProps
except AttributeError:
# Not controlled by a sizer.
@@ -235,9 +232,12 @@
def _diffSizerItemProps(self, dct, szOrDict, direct=False):
"""Remove all of the default values from the sizer item
props."""
- # First, what type of sizer is it?
- is2D = isinstance(szOrDict, dabo.ui.dGridSizer)
- defaults = {True: szItemDefaults[2], False:
szItemDefaults[1]}[is2D].copy()
+ if direct:
+ defaults = szOrDict
+ else:
+ # First, what type of sizer is it?
+ is2D = isinstance(szOrDict, dabo.ui.dGridSizer)
+ defaults = {True: szItemDefaults[2], False:
szItemDefaults[1]}[is2D].copy()
if isinstance(self, LayoutPanel):
defaults["Expand"] = True
defaults["Proportion"] = 1
@@ -376,9 +376,9 @@
kidDict = [cd for cd in
childDict
if
cd["attributes"]["classID"] == kidID][0]
except StandardError, e:
- kidDict = None
- except:
- pass
+ kidDict = {}
+ except AttributeError:
+ kidDict = {}
ret.append(kid.getDesignerDict(itemNum=numItems,
classDict=kidDict))
@@ -419,9 +419,9 @@
szDict = [cd for cd in childDict
if
cd["attributes"]["classID"] == szID][0]
except StandardError, e:
- szDict = None
- except:
- pass
+ szDict = {}
+ except AttributeError:
+ szDict = {}
ret.append(sz.getDesignerDict(itemNum=len(ret),
classDict=szDict))
return ret
@@ -495,7 +495,7 @@
return
try:
self._defaultSizerProps =
self.ControllingSizer.getItemProps(self)
- except:
+ except AttributeError:
self._defaultSizerProps = {}
@@ -885,7 +885,7 @@
pos = self.getPositionInSizer()
try:
sizerAtts =
self.getDesignerDict()["attributes"]["sizerInfo"]
- except:
+ except KeyError:
sizerAtts = None
cs.remove(self)
dabo.ui.callAfter(self.release)
@@ -945,6 +945,7 @@
class LayoutSizerMixin(LayoutSaverMixin):
def __init__(self, *args, **kwargs):
+ self.isDesignerSizer = True
super(LayoutSizerMixin, self).__init__(*args, **kwargs)
@@ -997,7 +998,7 @@
try:
defProps =
self.Controller.getDefaultSizerProps(kidItem.superControl)
itmDiffDict = self._diffSizerItemProps(itmDict,
defProps, direct=True)
- except:
+ except AttributeError:
itmDiffDict = self._diffSizerItemProps(itmDict,
self)
if kidItem in self.ChildWindows:
winDict = None
@@ -1008,9 +1009,9 @@
winDict = [cd for cd in
childDict
if
cd["attributes"]["classID"] == winID][0]
except StandardError, e:
- winDict = None
- except:
- pass
+ winDict = {}
+ except AttributeError:
+ winDict = {}
kidDict =
kidItem.getDesignerDict(itemNum=numItems,
classDict=winDict)
@@ -1023,9 +1024,9 @@
szrDict = [cd for cd in
childDict
if
cd["attributes"]["classID"] == szrID][0]
except StandardError, e:
- szrDict = None
- except:
- pass
+ szrDict = {}
+ except AttributeError:
+ szrDict = {}
kidDict =
kidItem.getDesignerDict(itemNum=numItems,
classDict=szrDict)
else:
@@ -1035,7 +1036,10 @@
pos = 1
else:
pos = 0
- spc = kidItem.Spacing
+ try:
+ spc = kidItem.Spacing
+ except AttributeError:
+ spc = 0
kidDict = {"name" : "Spacer",
"attributes" : {"size" : spc, "Name" :
"spacer"},
"cdata" : "",
@@ -1163,6 +1167,7 @@
"DefaultBorderRight": {"type" : bool,
"readonly" : False},
"DefaultBorderTop": {"type" : bool, "readonly"
: False},
"DefaultBorderBottom": {"type" : bool,
"readonly" : False},
+ "DefaultSpacing": {"type" : int, "readonly" :
False},
"SlotCount" : {"type": int, "readonly" : False}}
# Add the controlling sizer props, if applicable
if self.ControllingSizer:
@@ -1528,7 +1533,7 @@
if cd["attributes"]["classID"]
== objID][0]
except StandardError, e:
ret = None
- except:
+ except AttributeError:
pass
return ret
Modified: branches/ed-ide/components/ClassDesigner/ClassDesignerControlMixin.py
===================================================================
--- branches/ed-ide/components/ClassDesigner/ClassDesignerControlMixin.py
2008-06-14 15:10:46 UTC (rev 4131)
+++ branches/ed-ide/components/ClassDesigner/ClassDesignerControlMixin.py
2008-06-14 15:30:34 UTC (rev 4132)
@@ -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},
@@ -774,7 +777,7 @@
sliderProps = {"Max": {"type" : int, "readonly" : False},
"Min": {"type" : int, "readonly" : False},
"ShowLabels" : {"type" : bool, "readonly" :
False}}
- splitterProps = { "MinimumPanelSize": {"type" : int,
"readonly" : False},
+ splitterProps = {"MinimumPanelSize": {"type" : int, "readonly"
: False},
"Orientation": {"type" : list, "readonly" :
False,
"values" : ["Horizontal", "Vertical"]},
"PanelClass" : {"type" : unicode, "readonly" :
False},
@@ -791,6 +794,12 @@
"ForceCase": {"type" : list, "readonly" : False,
"values" : ["Upper", "Lower", "Title",
"None"]},
"ReadOnly" : {"type" : bool, "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},
"ShowButtons" : {"type" : bool, "readonly" :
False},
@@ -877,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)
@@ -936,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)
@@ -959,6 +970,9 @@
if isinstance(self, dabo.ui.dTextBox):
ret.update({"PasswordEntry" : {"type" : bool,
"readonly" : False},
"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: branches/ed-ide/components/ClassDesigner/ClassDesignerFormMixin.py
===================================================================
--- branches/ed-ide/components/ClassDesigner/ClassDesignerFormMixin.py
2008-06-14 15:10:46 UTC (rev 4131)
+++ branches/ed-ide/components/ClassDesigner/ClassDesignerFormMixin.py
2008-06-14 15:30:34 UTC (rev 4132)
@@ -483,9 +483,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 +1005,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: branches/ed-ide/components/ClassDesigner/ClassDesignerPropSheet.py
===================================================================
--- branches/ed-ide/components/ClassDesigner/ClassDesignerPropSheet.py
2008-06-14 15:10:46 UTC (rev 4131)
+++ branches/ed-ide/components/ClassDesigner/ClassDesignerPropSheet.py
2008-06-14 15:30:34 UTC (rev 4132)
@@ -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]