daboide Commit
Revision 860
Date: 2007-07-05 16:21:25 -0700 (Thu, 05 Jul 2007)
Author: Ed
Trac: http://svn.dabodev.com/trac/daboide/changeset/860
Changed:
U trunk/ClassDesigner.py
Log:
Trailing whitespace removed.
Diff:
Modified: trunk/ClassDesigner.py
===================================================================
--- trunk/ClassDesigner.py 2007-07-05 23:20:44 UTC (rev 859)
+++ trunk/ClassDesigner.py 2007-07-05 23:21:25 UTC (rev 860)
@@ -35,14 +35,14 @@
class ClassDesigner(dabo.dApp):
# Behaviors which are normal in the framework may need to
- # be modified when run as the ClassDesigner. This flag will
+ # be modified when run as the ClassDesigner. This flag will
# distinguish between the two states.
isDesigner = True
def __init__(self, clsFile=""):
super(ClassDesigner, self).__init__(showSplashScreen=False,
splashTimeout=10)
-
+
self._basePrefKey = "dabo.ide.ClassDesigner"
self._desFormClass = None
self._selectedClass = dui.dForm
@@ -65,7 +65,7 @@
self._superClassInfo = {}
self._addingClass = False
# Tuple of all paged-control classes
- self.pagedControls = (dui.dPageFrame, dui.dPageList,
dui.dPageSelect,
+ self.pagedControls = (dui.dPageFrame, dui.dPageList,
dui.dPageSelect,
dui.dPageFrameNoTabs)
self.MainFormClass = None
self.setAppInfo("appName", "Class Designer")
@@ -87,7 +87,7 @@
# Flag for indicating that all props, not just non-default ones,
# are saved in the .cdxml file
self.saveAllProps = False
- # When we set the DefaultBorder for a sizer, should we
+ # When we set the DefaultBorder for a sizer, should we
# resize all its children?
self._propagateDefaultBorder = True
# Store the name of the custom class menu here instead of
@@ -96,7 +96,7 @@
# Add this to the persistent MRUs
self._persistentMRUs[self._customClassCaption] =
self.addCustomClass
# Save the default atts for sizers. This way we can distinguish
- # from default sizers that can be replaced from customized
+ # from default sizers that can be replaced from customized
# sizers which should remain.
self._defBoxSizerAtts = bsa = {}
atts =
LayoutSizer().getDesignerDict(allProps=True)["attributes"]
@@ -113,41 +113,41 @@
# Get rid of the update/refresh delays
dabo.useUpdateDelays = False
-
- # Define the controls that can be added to the ClassDesigner.
The
+
+ # Define the controls that can be added to the ClassDesigner.
The
# 'order' value will determine their order in the menu. One plan
# is to keep track of the user's choices, and weight the orders
# so that their most frequent choices are at the top.
- self.designerControls = ({"name" : "Box", "class" : dui.dBox,
"order" : 0},
- {"name" : "Bitmap", "class" : dui.dBitmap,
"order" : 10},
- {"name" : "BitmapButton", "class" :
dui.dBitmapButton, "order" : 20},
- {"name" : "Button", "class" : dui.dButton,
"order" : 30},
- {"name" : "CheckBox", "class" : dui.dCheckBox,
"order" : 40},
- {"name" : "CodeEditor", "class" : dui.dEditor,
"order" : 45},
- {"name" : "ComboBox", "class" : dui.dComboBox,
"order" : 50},
- {"name" : "DateTextBox", "class" :
dui.dDateTextBox, "order" : 60},
- {"name" : "DropdownList", "class" :
dui.dDropdownList, "order" : 70},
- {"name" : "EditBox", "class" : dui.dEditBox,
"order" : 80},
- {"name" : "Gauge", "class" : dui.dGauge,
"order" : 90},
- {"name" : "Grid", "class" : dui.dGrid, "order"
: 100},
- {"name" : "Image", "class" : dui.dImage,
"order" : 110},
- {"name" : "Label", "class" : dui.dLabel,
"order" : 120},
- {"name" : "Line", "class" : dui.dLine, "order"
: 130},
- {"name" : "ListBox", "class" : dui.dListBox,
"order" : 140},
- {"name" : "ListControl", "class" :
dui.dListControl, "order" : 150},
- {"name" : "RadioList", "class" :
dui.dRadioList, "order" : 160},
- {"name" : "Page", "class" : dui.dPage, "order"
: 170},
- {"name" : "Panel", "class" : dui.dPanel,
"order" : 180},
- {"name" : "ScrollPanel", "class" :
dui.dScrollPanel, "order" : 190},
- {"name" : "PageFrame", "class" :
dui.dPageFrame, "order" : 200},
- {"name" : "PageList", "class" : dui.dPageList,
"order" : 210},
- {"name" : "PageSelect", "class" :
dui.dPageSelect, "order" : 220},
- {"name" : "PageFrameNoTabs", "class" :
dui.dPageFrameNoTabs, "order" : 230},
- {"name" : "Slider", "class" : dui.dSlider,
"order" : 240},
- {"name" : "Spinner", "class" : dui.dSpinner,
"order" : 250},
- {"name" : "Splitter", "class" : dui.dSplitter,
"order" : 260},
- {"name" : "TextBox", "class" : dui.dTextBox,
"order" : 270},
- {"name" : "ToggleButton", "class" :
dui.dToggleButton, "order" : 280},
+ self.designerControls = ({"name" : "Box", "class" : dui.dBox,
"order" : 0},
+ {"name" : "Bitmap", "class" : dui.dBitmap,
"order" : 10},
+ {"name" : "BitmapButton", "class" :
dui.dBitmapButton, "order" : 20},
+ {"name" : "Button", "class" : dui.dButton,
"order" : 30},
+ {"name" : "CheckBox", "class" : dui.dCheckBox,
"order" : 40},
+ {"name" : "CodeEditor", "class" : dui.dEditor,
"order" : 45},
+ {"name" : "ComboBox", "class" : dui.dComboBox,
"order" : 50},
+ {"name" : "DateTextBox", "class" :
dui.dDateTextBox, "order" : 60},
+ {"name" : "DropdownList", "class" :
dui.dDropdownList, "order" : 70},
+ {"name" : "EditBox", "class" : dui.dEditBox,
"order" : 80},
+ {"name" : "Gauge", "class" : dui.dGauge,
"order" : 90},
+ {"name" : "Grid", "class" : dui.dGrid, "order"
: 100},
+ {"name" : "Image", "class" : dui.dImage,
"order" : 110},
+ {"name" : "Label", "class" : dui.dLabel,
"order" : 120},
+ {"name" : "Line", "class" : dui.dLine, "order"
: 130},
+ {"name" : "ListBox", "class" : dui.dListBox,
"order" : 140},
+ {"name" : "ListControl", "class" :
dui.dListControl, "order" : 150},
+ {"name" : "RadioList", "class" :
dui.dRadioList, "order" : 160},
+ {"name" : "Page", "class" : dui.dPage, "order"
: 170},
+ {"name" : "Panel", "class" : dui.dPanel,
"order" : 180},
+ {"name" : "ScrollPanel", "class" :
dui.dScrollPanel, "order" : 190},
+ {"name" : "PageFrame", "class" :
dui.dPageFrame, "order" : 200},
+ {"name" : "PageList", "class" : dui.dPageList,
"order" : 210},
+ {"name" : "PageSelect", "class" :
dui.dPageSelect, "order" : 220},
+ {"name" : "PageFrameNoTabs", "class" :
dui.dPageFrameNoTabs, "order" : 230},
+ {"name" : "Slider", "class" : dui.dSlider,
"order" : 240},
+ {"name" : "Spinner", "class" : dui.dSpinner,
"order" : 250},
+ {"name" : "Splitter", "class" : dui.dSplitter,
"order" : 260},
+ {"name" : "TextBox", "class" : dui.dTextBox,
"order" : 270},
+ {"name" : "ToggleButton", "class" :
dui.dToggleButton, "order" : 280},
{"name" : "TreeView", "class" : dui.dTreeView,
"order" : 290}
)
self._initSizerDefaults()
@@ -166,7 +166,7 @@
if not clsOK:
# Define the form class, and instantiate it.
frmClass = self.getFormClass()
-
+
# Temp! for development
# useSz = not os.path.exists("/Users/ed/dls")
# frm = frmClass(UseSizers=useSz)
@@ -179,32 +179,32 @@
frm._initialStateDict = {}
frm.Controller = self
self.MainForm = frm
- # When more than one ClassDesigner is open, this will
+ # When more than one ClassDesigner is open, this will
# hold the active reference.
self.CurrentForm = frm
- # Create the form the holds the PropSheet, Method listing
- # and object tree if it hasn't already been created.
- pf = self._pemForm
+ # Create the form the holds the PropSheet, Method listing
+ # and object tree if it hasn't already been created.
+ pf = self._pemForm
if pf is None:
pf = self._pemForm = PemForm(None)
pf.Controller = self
pf.Visible = True
-
+
# Create the control palette
palette = self.ControlPalette
palette.Controller = self
palette.Visible = False
-
+
# Create the sizer palette, but make it hidden to start
palette = self.SizerPalette
palette.Controller = self
palette.Visible = False
-
+
# Create the Code Editor
ed = self.EditorForm
ed.Controller = self
ed.Visible = True
-
+
# Set the initial selection to the form
self.select(self.CurrentForm)
@@ -214,23 +214,23 @@
dui.callAfter(frm.bringToFront)
dui.callAfter(frm.saveState)
self.start()
-
-
+
+
def addToAbout(self):
""" Add the IDE version."""
from __version__ import version
return "Dabo IDE version: %(version)s (Revision %(revision)s)"
% version
-
-
-
+
+
+
def _initSizerDefaults(self):
"""Create a dict containing the sizer default settings
for each designer class.
"""
self._sizerDefaults = {}
- defVals = {"BorderSides": ["All"], "Proportion": 1, "HAlign":
"Left",
+ defVals = {"BorderSides": ["All"], "Proportion": 1, "HAlign":
"Left",
"VAlign": "Top", "Border": 0, "Expand": True}
- # Use the defaults for each class, except where specified
+ # Use the defaults for each class, except where specified
dct = defVals.copy()
self._sizerDefaults[dui.dBox] = dct
dct = defVals.copy()
@@ -330,23 +330,23 @@
dct = defVals.copy()
dct.update({"HAlign" : "center", "VAlign" : "middle"})
self._sizerDefaults[dui.dTreeView] = dct
- return
-
-
+ return
+
+
def _initClassEvents(self):
"""Create a dict by baseclass of all applicable events."""
self._classEvents = {}
self._classMethods = {}
- baseEvents = ("DataEvent", "EditorEvent", "GridEvent",
"KeyEvent",
- "ListEvent", "MenuEvent", "MouseEvent",
"SashEvent",
+ 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.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,
+ 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.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)
def evtsForClass(cls):
@@ -362,7 +362,7 @@
pass
ret.sort()
return ret
-
+
def mthdsForClass(cls):
ret = []
mthds = inspect.getmembers(cls, inspect.ismethod)
@@ -373,8 +373,8 @@
for cls in classes:
self._classEvents[cls] = evtsForClass(cls)
self._classMethods[cls] = mthdsForClass(cls)
-
-
+
+
def getFormClass(self):
"""If the selected class is a form/dialog, return a mixed-in
subclass of it. Otherwise, return the base ClassDesignerForm.
@@ -406,7 +406,7 @@
self._designerMode = True
self._formMode = True
super(DesForm, self)._afterInit()
-
+
def addControls(self):
if not isinstance(self, dui.dOkCancelDialog):
# Could be a wizard, or some other
object with an 'addControls' method
@@ -426,8 +426,8 @@
self.btnOK.unbindEvent(dEvents.Hit)
self.btnCancel.unbindEvent(dEvents.Hit)
self.btnOK.Enabled = self.btnCancel.Enabled =
False
-
-
+
+
def _setupPanels(self, fromNew=True):
if isinstance(self, dlgs.Wizard):
self.mainPanel = self.pagePanel
@@ -456,10 +456,10 @@
# Prevent the Finish button from
closing the design surface.
self.finish = lambda: False
return
-
+
if self.UseSizers:
if isinstance(self,
dui.dOkCancelDialog):
- # already done
+ # already done
return
self.Sizer = dui.dSizer("v")
self.mainPanel = LayoutBasePanel(self)
@@ -476,11 +476,11 @@
if formIsMain:
self._desFormClass = ret
return ret
-
+
def _reuseMainForm(self, useSizers=False):
"""Determines if the MainForm for the Class Designer is a
blank, unedited
- form, which can be re-used when the user opens an existing
class or
+ form, which can be re-used when the user opens an existing
class or
creates a new class.
"""
mf = self.MainForm
@@ -490,25 +490,25 @@
mfCurrDict = mf.getDesignerDict()
# Position and size of the form may have changed;
delete those
# since they are irrelevant. Also, it seems that on
Windows these
- # atts are set while the object is being created, so we
have to
+ # atts are set while the object is being created, so we
have to
# clear them in the _initialStateDict, too.
for att in ("Left", "Top", "Width", "Height"):
try:
del mfCurrDict["attributes"][att]
- except: pass
+ except: pass
try:
del
mf._initialStateDict["attributes"][att]
except: pass
ret = mf and (mf._initialStateDict == mfCurrDict)
return ret
-
-
+
+
def onEditUndo(self, evt):
dabo.infoLog.write(_("Not implemented yet"))
def onEditRedo(self, evt):
dabo.infoLog.write(_("Not implemented yet"))
-
-
+
+
def _importClassXML(self, pth):
"""Read in the XML and associated code file (if any), and
return a dict that can be used to re-create the object.
@@ -517,7 +517,7 @@
dct = xtd.xmltodict(pth, addCodeFile=True)
except:
raise IOError, _("This does not appear to be a valid
class file.")
-
+
# Traverse the dct, looking for superclass information
super = xtd.flattenClassDict(dct)
if super:
@@ -527,27 +527,27 @@
# modified it.
self._updateClassCodeRepository(super)
return dct
-
-
+
+
def _updateClassCodeRepository(self, dct):
"""Take a flattened dict of class IDs and store any code
- associated with those IDs, so that we can later compare it to
+ associated with those IDs, so that we can later compare it to
an object's code in order to determine if it has been changed.
"""
cds = [(kk, vv["code"]) for kk, vv in dct.items()
if vv["code"]]
for cd in cds:
self._classCodeDict.update({cd[0]: cd[1]})
-
+
def _getClassMethod(self, clsID, mthd):
"""Given a class ID and a method name, returns the code for that
classID/method combination (if any) from self._classCodeDict.
"""
cd = self._classCodeDict.get(clsID, {})
return cd.get(mthd, "")
-
-
+
+
def _findSizerInClassDict(self, clsd):
"""Recursively search until a child is found with sizer
information.
If no such child is found, return False.
@@ -564,11 +564,11 @@
if ret:
break
return ret
-
-
+
+
def openClass(self, pth):
- """Called when the user selects the 'Open' menu and selects
- a saved XML file. We need to open the file, and confirm that it
is
+ """Called when the user selects the 'Open' menu and selects
+ a saved XML file. We need to open the file, and confirm that it
is
indeed a valid class file. If so, we then re-construct the
class in
a new ClassDesigner window.
"""
@@ -588,7 +588,7 @@
clsd["name"] = clsname
except ValueError:
clsd["fullname"] = nm
-
+
# See if it is a full form-based class, or an individual
component.
isFormClass = (clsd["name"] in ("dForm", "dDialog",
"dOkCancelDialog", "Wizard"))
if isFormClass:
@@ -598,11 +598,11 @@
else:
atts = {"UseSizers": self._findSizerInClassDict(clsd)}
nm = "ClassDesignerForm"
-
+
isDlg = (clsd["name"] in ("dDialog", "dOkCancelDialog",
"Wizard"))
isWiz = (clsd["name"] in ("Wizard",))
if isDlg:
- self._selectedClass = {"dDialog": dui.dDialog,
+ self._selectedClass = {"dDialog": dui.dDialog,
"dOkCancelDialog": dui.dOkCancelDialog,
"Wizard": dlgs.Wizard}[clsd["name"]]
@@ -619,7 +619,7 @@
frmClass = self.getFormClass()
if isWiz:
self._extractKey(atts, "PageCount")
- frm = frmClass(None, Name=nm,
SaveRestorePosition=False,
+ frm = frmClass(None, Name=nm, SaveRestorePosition=False,
attProperties=atts)
if isWiz:
self._recreateWizardPages(frm, clsd["children"])
@@ -684,10 +684,10 @@
frm.Visible = True
# Save the initial state
frm.saveState()
-
+
return frm
-
-
+
+
def extractSuperClassInfo(self, pth):
try:
superdct = xtd.xmltodict(pth, addCodeFile=True)
@@ -700,19 +700,19 @@
self._updateClassCodeRepository(sup)
# Add it to the current class definitions
self._superClassInfo.update(sup)
-
-
+
+
def inherit(self, dct):
super = self._superClassInfo
if super:
# We need to modify the info to incorporate the
superclass info
xtd.addInheritedInfo(dct, super)
return dct
-
-
+
+
def recreateChildren(self, parent, chld, szr, fromSzr, debug=0):
- """Recursive routine to re-create the sizer/object structure of
- the class.
+ """Recursive routine to re-create the sizer/object structure of
+ the class.
"""
ret = None
if isinstance(chld, dict):
@@ -745,11 +745,11 @@
sizerInfoDict = eval(sizerInfo)
else:
sizerInfoDict = sizerInfo
-
+
rowColAtts = self._extractKey(atts, "rowColPos",
"(None,None)")
if clsname == "LayoutPanel":
# Panel has already been created by the sizer's
slots;
- # just set any sizer item props.
+ # just set any sizer item props.
pnl = self._srcObj
sz = pnl.ControllingSizer
itm = pnl.ControllingSizerItem
@@ -758,7 +758,7 @@
pnl.classID = classID
if kids:
self.recreateChildren(pnl, kids, None,
False)
-
+
elif clsname == "LayoutSpacerPanel":
spc = int(atts.get("Spacing", "20"))
pnl = self._srcObj
@@ -776,7 +776,7 @@
if classID:
obj.classID = classID
ret = obj
-
+
elif clsname in ("LayoutSizer", "LayoutBorderSizer"):
ornt = self._extractKey(atts, "Orientation",
"h")
slots = int(self._extractKey(atts, "SlotCount",
"1"))
@@ -790,12 +790,12 @@
itm = sz.ControllingSizerItem
is2D = isinstance(szCont, dabo.ui.dGridSizer)
- defaults = {True:
LayoutSaverMixin.szItemDefaults2D,
+ defaults = {True:
LayoutSaverMixin.szItemDefaults2D,
False:
LayoutSaverMixin.szItemDefaults1D}[is2D]
defAtts = {}
for key, val in defaults.items():
defAtts["Sizer_%s" % key] = val
- defAtts.update(dictStringify(atts))
+ defAtts.update(dictStringify(atts))
atts = defAtts
sz.setPropertiesFromAtts(atts)
if classID:
@@ -805,31 +805,31 @@
if szCont is not None and itm is not None:
szCont.setItemProps(itm, sizerInfoDict)
if kids:
- # We need to set the value of _srcObj
to the individual
- # LayoutPanel in the sizer. The number
of kids should
+ # We need to set the value of _srcObj
to the individual
+ # LayoutPanel in the sizer. The number
of kids should
# match the number of slots created
when the sizer
# was created.
childWindowList = sz.ChildWindows[:]
for pos, kid in enumerate(kids):
# Set the LayoutPanel to the
'source' object
pnl = self._srcObj =
childWindowList[pos]
- # Pass the 'kid' as a list,
since that's what
+ # Pass the 'kid' as a list,
since that's what
# recreateChildren() expects.
self.recreateChildren(parent,
[kid], sz, True)
ret = sz
-
+
elif clsname == "LayoutGridSizer":
rows = int(self._extractKey(atts, "Rows", "1"))
cols = int(self._extractKey(atts, "Columns",
"1"))
sz, pnl = self.addSizer("grid", rows=rows,
cols=cols)
szCont = sz.ControllingSizer
is2D = isinstance(szCont, dabo.ui.dGridSizer)
- defaults = {True:
LayoutSaverMixin.szItemDefaults2D,
+ defaults = {True:
LayoutSaverMixin.szItemDefaults2D,
False:
LayoutSaverMixin.szItemDefaults1D}[is2D]
defAtts = {}
for key, val in defaults.items():
defAtts["Sizer_%s" % key] = val
- defAtts.update(dictStringify(atts))
+ defAtts.update(dictStringify(atts))
atts = defAtts
sz.setPropertiesFromAtts(atts)
if not fromSzr:
@@ -849,7 +849,7 @@
row, col =
eval(kidatts.get("rowColPos"))
# Set the LayoutPanel to the
'source' object
pnl = self._srcObj =
sz.getItemByRowCol(row, col)
- # Pass the 'kid' as a list,
since that's what
+ # Pass the 'kid' as a list,
since that's what
# recreateChildren() expects.
obj =
self.recreateChildren(parent, [kid], sz, True)
ret = sz
@@ -867,7 +867,7 @@
# they may be pasting
into a grid sizer.
self._srcObj =
szr.getItemByRowCol(row, col)
props = {}
-
+
try:
imp, clsname = cls.rsplit(".", 1)
imptSt = "from %(imp)s import
%(clsname)s" % locals()
@@ -878,7 +878,7 @@
except ValueError:
dct["fullname"] = cls
newClass = dui.__dict__[cls]
-
+
isGrid = issubclass(newClass, dui.dGrid)
isTree = issubclass(newClass, dui.dTreeView)
isSplitter = issubclass(newClass, dui.dSplitter)
@@ -912,7 +912,7 @@
# Name value, so change it to NameBase.
nm = self._extractKey(atts, "Name", clsname)
props["NameBase"] = nm
- obj = self.addNewControl(None, newClass,
props=props,
+ obj = self.addNewControl(None, newClass,
props=props,
skipUpdate=True,
attProperties=atts)
ret = obj
if isSplitter:
@@ -925,7 +925,7 @@
sz.setItemProps(itm, sizerInfoDict)
if classID:
obj.classID = classID
-
+
for mthd, cd in code.items():
if not self._codeDict.get(obj):
self._codeDict[obj] = {}
@@ -934,7 +934,7 @@
# Restore any prop definitions.
if propDefs:
self._classPropDict[obj] = propDefs
-
+
if kids:
if isGrid:
# All the kids will be columns,
so add 'em here
@@ -944,7 +944,7 @@
# Make it look nice
obj.emptyRowsToAdd = 5
obj.fillGrid(True)
-
+
elif isPageControl:
for pos, kid in enumerate(kids):
pg = obj.Pages[pos]
@@ -959,8 +959,8 @@
grandkids =
kid.get("children", [])
if grandkids:
self._srcObj =
pg
-
self.recreateChildren(pg, grandkids, None, False)
-
+
self.recreateChildren(pg, grandkids, None, False)
+
elif isSplitter:
for pos, kid in enumerate(kids):
pnlClass =
dui.__dict__[kid["name"]]
@@ -972,7 +972,7 @@
if pnl is None:
continue
kidatts =
kid.get("attributes", {})
-
pnl.setPropertiesFromAtts(kidatts)
+
pnl.setPropertiesFromAtts(kidatts)
kidcode =
kid.get("code", {})
if kidcode:
self._codeDict[pnl] = kidcode
@@ -982,7 +982,7 @@
self._srcObj =
pnl
self.recreateChildren(pnl, grandkids, None, False)
self._srcObj =
curr
-
+
elif isTree:
def addTreeNode(parent, atts,
kidnodes):
cap =
self._extractKey(atts, "Caption", "")
@@ -1091,8 +1091,8 @@
dlg.edtSuper.ReadOnly = True
dlg.show()
dlg.release()
-
-
+
+
def onDeclareImports(self, evt):
"""Show a dialog that enables the user to edit the import
statements
that will be included with the code when this class is run.
@@ -1110,15 +1110,15 @@
self.edtImport = dui.dEditor(self,
ShowLineNumbers=False,
ShowCodeFolding=False)
self.Sizer.append1x(self.edtImport, border=12)
-
+
dlg = ImportEditDialog(None,
BasePrefKey=self.BasePrefKey+".ImportEditDialog")
dlg.edtImport.Text = txt
dlg.show()
if dlg.Accepted:
self._classImportDict[frm] = dlg.edtImport.Text
dlg.release()
-
-
+
+
def addToImportDict(self, txt):
"""Adds the passed line(s) to the import statements."""
if isinstance(txt, (list, tuple)):
@@ -1131,8 +1131,8 @@
if txt not in impLines:
imp += "\n%s" % txt
self._classImportDict[frm] = imp
-
-
+
+
def getImportDict(self, frm=None):
"""Returns the import statements for the requested form,
or the current form if no form is specified.
@@ -1140,8 +1140,8 @@
if frm is None:
frm = self.CurrentForm
return self._classImportDict.get(frm, "")
-
-
+
+
def setProp(self, obj, prop, val, typ):
if prop == "Font":
obj.Font = val
@@ -1157,7 +1157,7 @@
else:
strVal = str(val)
if typ in (str, unicode) or ((typ is list) and
isinstance(val, basestring)):
- # Escape any single quotes, and then enclose
+ # Escape any single quotes, and then enclose
# the value in single quotes
strVal = "u'" + self.escapeQt(strVal) + "'"
try:
@@ -1167,7 +1167,7 @@
def updatePropVal(self, prop, val, typ):
- """Called whenever the user edits a property. We need to
+ """Called whenever the user edits a property. We need to
update the object accordingly.
"""
updTreeAll = prop in ("ColumnCount", "SlotCount")
@@ -1182,13 +1182,13 @@
self.setProp(obj, prop, val,
typ)
else:
sz.setItemProp(obj.ControllingSizerItem, prop, val)
-
+
elif isinstance(obj, dui.dSizer):
self.setProp(obj, prop, val, typ)
updTreeAll = True
else:
self.setProp(obj, prop, val, typ)
-
+
fillGrid = False
if isinstance(obj, dui.dGrid) and prop == "ColumnCount":
gridObj = obj
@@ -1204,7 +1204,7 @@
if fillGrid:
gridObj.emptyRowsToAdd = 5
gridObj.fillGrid(True)
-
+
self.CurrentForm.layout()
if updTreeAll:
self.Tree.updateDisplay(self.CurrentForm)
@@ -1213,10 +1213,10 @@
if prop == "Name":
# Need to update the object list in the code editor
self.EditorForm.refreshObjectList(force=True)
-
-
+
+
def editSizerSettings(self, obj):
- """Display a dialog that will allow the user to edit all the
sizer
+ """Display a dialog that will allow the user to edit all the
sizer
settings in one place.
"""
class SizerEditDlg(dui.dOkCancelDialog):
@@ -1227,17 +1227,17 @@
super(SizerEditDlg, self).__init__(*args,
**kwargs)
# Set the expand enable/disable
self.onExpandChange()
-
+
def addControls(self):
if self._fillFunc:
self._fillFunc(self)
-
+
def onExpandChange(self, evt=None):
if self.expandControl is not None:
enab = not self.expandControl.Value
for ctl in self. alignControls:
ctl.Enabled = enab
-
+
isSpacer = isinstance(obj, LayoutSpacerPanel)
isSlot = isinstance(obj, LayoutPanel)
isSizer = isinstance(obj, dui.dSizerMixin)
@@ -1262,18 +1262,18 @@
if not prop.startswith(prefix)]
else:
selfProps = []
-
+
propDict = dict.fromkeys(szProps)
for prop in szProps:
if isSlot and not (prop == "Spacing"):
propDict[prop] = csz.getItemProp(cszIt, prop)
else:
propDict[prop] = obj.__getattribute__(prop)
-
+
selfPropDict = dict.fromkeys(selfProps)
for prop in selfProps:
selfPropDict[prop] = obj.__getattribute__(prop)
-
+
if csz:
isInGrid = isinstance(csz, dui.dGridSizer)
isInVert = csz.Orientation.lower()[0] == "v"
@@ -1295,7 +1295,7 @@
# Add a separator between
sections if there are props
# in both lists.
dlg.Sizer.appendSpacer(6)
-
+
bx = dui.dBorderSizer(dlg)
if propSource == szProps:
bx.Caption = _("Controlling
Sizer Properties")
@@ -1306,7 +1306,7 @@
else:
# Just one section, so add the grid to
the dialog's sizer
dlg.Sizer.append(sz, border=20)
-
+
for prop in propSource:
lowprop = prop.lower()
if lowprop.endswith("bordersides"):
@@ -1320,7 +1320,7 @@
continue
elif isInVert and
lowprop.endswith("valign"):
# Not needed
- continue
+ continue
ctl = dui.dDropdownList(dlg)
if lowprop.endswith("halign"):
ctl.Choices = ["Left",
"Center", "Right"]
@@ -1342,9 +1342,9 @@
ctl = dui.dTextBox(dlg,
Value=val)
# Create the label
lbl = dui.dLabel(dlg,
Caption=prop.replace(prefix, ""))
-
+
# TOOLTIP
-# ctl.ToolTipText =
+# ctl.ToolTipText =
# Add 'em to the grid sizer
sz.append(lbl, halign="Right")
sz.append(ctl)
@@ -1355,7 +1355,7 @@
ctl.DataField = "Sizer_%s" %
prop
else:
ctl.DataField = prop
-
+
# Create dynamic bindings for the
Expand control
bareLowprop = prop.replace(prefix,
"").lower()
if bareLowprop == "expand":
@@ -1363,17 +1363,17 @@
dlg.expandControl = ctl
elif bareLowprop.endswith("align"):
dlg.alignControls.append(ctl)
-
-
+
+
# OK, we've defined the code for creating the dialog on the fly.
# Now let's run it. If they click OK, the values will already
be set
- # by the data binding. If they cancel, we have to revert them
to
+ # by the data binding. If they cancel, we have to revert them to
# the values in propDict.
self._sizerObj = obj
dlg = SizerEditDlg(fillDlg,
BasePrefKey=self.BasePrefKey+".SizerEditDlg")
dlg.Caption = _("Sizer Settings")
self.CurrentForm.bringToFront()
- # This is used to determine if anything has changed in
+ # This is used to determine if anything has changed in
# the dialog, so we know whether to update or not.
self._szDlg = dlg
self._szDlgVals = self._getSzDlgVals()
@@ -1395,14 +1395,14 @@
propName = prefix + prop
obj.__setattr__(propName, val)
self.CurrentForm.layout()
-
+
dlg.release()
self._szDlg = None
self._szDlgVals = {}
self._sizerObj = None
self.CurrentForm.bringToFront()
-
-
+
+
def _getSzDlgVals(self):
ret = {}
for ctl in self._szDlg.Children:
@@ -1411,26 +1411,26 @@
if df:
ret[df] = ctl.Value
return ret
-
-
+
+
def updInBackground(self):
currVals = self._getSzDlgVals()
if currVals != self._szDlgVals:
self._szDlgVals = currVals
self.CurrentForm.layout()
-
-
+
+
def _setSlotProp(self, val):
print "VAL", val, self._sizerObj
-
-
+
+
def _getSel(self):
"""Convenience method used only for debugging. Don't
count on this method remaining in the code!!!!
"""
return self._selection[0]
-
-
+
+
def getDefaultValues(self, srcObj):
"""Given an object's class, returns a dict containing its
DesignerProps as keys, and the default value for each as values.
@@ -1454,7 +1454,7 @@
else:
frm = dui.dForm(None)
# We need to handle all the dependent class
types
- if issubclass(cls, dui.dPage) and
isinstance(srcObj.Parent,
+ if issubclass(cls, dui.dPage) and
isinstance(srcObj.Parent,
self.pagedControls):
pgf = srcObj.Parent
pp = pgf.PageCount
@@ -1477,15 +1477,15 @@
self._classDefaultVals[cls] = ret
if cleanup:
exec cleanup in locals()
-
+
if not issubclass(cls, dui.dPage):
# Pages will be released by their parent.
obj.release()
if frm:
frm.release()
return ret
-
-
+
+
def onEditCut(self, evt):
handled = False
if self.ActiveForm == self.CurrentForm:
@@ -1496,8 +1496,8 @@
else:
# Normal cut operation
super(ClassDesigner, self).onEditCut(evt)
-
-
+
+
def onEditCopy(self, evt):
handled = False
if self.ActiveForm == self.CurrentForm:
@@ -1508,8 +1508,8 @@
else:
# Normal cut operation
super(ClassDesigner, self).onEditCopy(evt)
-
-
+
+
def onEditPaste(self, evt):
handled = False
if self.ActiveForm == self.CurrentForm:
@@ -1525,7 +1525,7 @@
pnl = self.CurrentForm.mainPanel
print "ACTIVE PANEL", pnl
-
+
if isinstance(pnl, LayoutPanel):
pnl.onPaste(evt)
handled = True
@@ -1537,8 +1537,8 @@
else:
# Normal cut operation
super(ClassDesigner, self).onEditPaste(evt)
-
-
+
+
def pasteObject(self, pnl, pos=None):
"""If there is a control's dict on the clipboard, re-create the
control
where the panel is located.
@@ -1564,13 +1564,13 @@
self.select(obj)
dui.callAfterInterval(100, self.updateLayout)
-
+
def copyObject(self, obj):
"""Place a copy of the passed control on the clipboard"""
dct = obj.getDesignerDict()
# We can't use the Name property, since it may conflict
# with the original control. So remove any trailing digits
- # and assign the result to the NameBase property, and
+ # and assign the result to the NameBase property, and
# delete the Name property.
atts = dct["attributes"]
# Convert any paths in the atts
@@ -1587,13 +1587,13 @@
# Put the result on the clipboard
self._clipboard = dct
-
+
def escapeQt(self, s):
sl = "\\"
qt = "\'"
return s.replace(sl, sl+sl).replace(qt, sl+qt)
-
+
def updateLayout(self):
"""Called whenever the sizer layout is changed. """
# Make sure that the selected objects are still 'live'
@@ -1621,24 +1621,24 @@
dabo.ui.callAfterInterval(200, self.ControlPalette.update)
dabo.ui.callAfterInterval(200, self.SizerPalette.update)
-
+
def flushCodeEditor(self):
self.EditorForm.updateText()
-
-
+
+
def onToggleSaveType(self, evt):
newSetting = not self.getUserSetting("saveCodeInXML", False)
self.setUserSetting("saveCodeInXML", newSetting)
-
-
+
+
def onSaveDesign(self, evt):
self.wrapSave(self.CurrentForm.onSaveDesign, evt)
def onSaveClassDesign(self, evt):
self.wrapSave(self.CurrentForm.onSaveClassDesign, evt)
-
-
+
+
def onRunDesign(self, evt):
self.flushCodeEditor()
self.CurrentForm.onRunDesign(evt)
@@ -1657,23 +1657,23 @@
def addControls(self):
# Create a dropdown list containing all the
choices.
# NOTE: This would be an excellent candidate
for usage ordering.
- chc = ("Form", "Panel", "ScrollPanel", "Plain
Dialog", "OK/Cancel Dialog",
- "Wizard", "WizardPage",
"PageFrame", "PageList", "PageSelect",
- "PageNoTabs", "Box", "Bitmap",
"BitmapButton", "Button", "CheckBox",
- "ComboBox", "DateTextBox",
"DropdownList", "EditBox", "Editor",
- "Gauge", "Grid", "Image",
"Label", "Line", "ListBox", "ListControl", "Page",
- "RadioList", "Slider",
"Spinner", "Splitter", "TextBox", "ToggleButton",
+ chc = ("Form", "Panel", "ScrollPanel", "Plain
Dialog", "OK/Cancel Dialog",
+ "Wizard", "WizardPage",
"PageFrame", "PageList", "PageSelect",
+ "PageNoTabs", "Box", "Bitmap",
"BitmapButton", "Button", "CheckBox",
+ "ComboBox", "DateTextBox",
"DropdownList", "EditBox", "Editor",
+ "Gauge", "Grid", "Image",
"Label", "Line", "ListBox", "ListControl", "Page",
+ "RadioList", "Slider",
"Spinner", "Splitter", "TextBox", "ToggleButton",
"TreeView")
- keys = (dui.dForm, dui.dPanel,
dui.dScrollPanel, dui.dDialog,
- dui.dOkCancelDialog,
dlgs.Wizard, dlgs.WizardPage,
- 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.dListBox, dui.dListControl,
dui.dPage, dui.dRadioList, dui.dSlider,
- dui.dSpinner, dui.dSplitter,
dui.dTextBox, dui.dToggleButton,
+ keys = (dui.dForm, dui.dPanel,
dui.dScrollPanel, dui.dDialog,
+ dui.dOkCancelDialog,
dlgs.Wizard, dlgs.WizardPage,
+ 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.dListBox, dui.dListControl,
dui.dPage, dui.dRadioList, dui.dSlider,
+ dui.dSpinner, dui.dSplitter,
dui.dTextBox, dui.dToggleButton,
dui.dTreeView)
- self.dd = dabo.ui.dDropdownList(self,
Choices=chc, Keys=keys,
+ self.dd = dabo.ui.dDropdownList(self,
Choices=chc, Keys=keys,
ValueMode="key")
self.dd.StringValue="Form"
self.dd.bindEvent(dEvents.Hit, self.onClassSel)
@@ -1683,20 +1683,20 @@
self.Sizer.appendSpacer(3)
self.Sizer.append1x(self.dd, halign="Center")
self.Sizer.appendSpacer(10)
-
+
self.chk = dabo.ui.dCheckBox(self, Value=True,
Caption=_("Use Sizers"))
self.Sizer.append(self.chk, halign="Center")
self.Sizer.appendSpacer(25)
-
+
def onClassSel(self, evt):
# This should be the key value, which is a
class name
cls = self.dd.KeyValue
- sizerClasses = (dui.dForm, dui.dPanel,
dui.dScrollPanel, dui.dDialog,
+ sizerClasses = (dui.dForm, dui.dPanel,
dui.dScrollPanel, dui.dDialog,
dui.dOkCancelDialog,
dlgs.Wizard, dlgs.WizardPage,
dui.dPage, dui.dSplitter) + pcs
self.chk.Visible = cls in sizerClasses
-
- dlg = NewClassPicker(self.CurrentForm, Caption=_("New Class"),
+
+ dlg = NewClassPicker(self.CurrentForm, Caption=_("New Class"),
BasePrefKey=self.BasePrefKey+".NewClassPicker")
dlg.show()
if not dlg.Accepted:
@@ -1709,7 +1709,7 @@
useSizers = dlg.chk.Visible and dlg.chk.Value
dlg.release()
- if (useSizers and not isDialog and self._reuseMainForm() and
+ if (useSizers and not isDialog and self._reuseMainForm() and
self.MainForm.UseSizers == useSizers):
# Original form hasn't changed, so just use it.
frm = self.MainForm
@@ -1723,15 +1723,15 @@
frm._formMode = isFormClass
if not isFormClass:
obj = self.addNewControl(frm.initLayoutPanel, newClass)
- frm.Caption = _("Dabo Class Designer: %s") % obj.Name
+ frm.Caption = _("Dabo Class Designer: %s") % obj.Name
frm.Visible = True
dui.callAfter(frm.bringToFront)
dui.callAfter(frm.saveState)
-
+
def wrapSave(self, func, *args, **kwargs):
- """Call the desired save method, and catch any error that is
raised,
- displaying it to the user. If no error occurs, return True;
otherwise,
+ """Call the desired save method, and catch any error that is
raised,
+ displaying it to the user. If no error occurs, return True;
otherwise,
return False.
"""
try:
@@ -1740,8 +1740,8 @@
except IOError, e:
dabo.ui.stop(_("Save failed; reason: %s") % e)
return False
-
-
+
+
def onSaveRunnable(self, evt):
if not self.wrapSave(self.CurrentForm.onSaveDesign, evt):
return
@@ -1759,8 +1759,8 @@
% out, title=_("Runnable App Saved"))
except IOError, e:
dabo.ui.stop(_("Save failed; reason: %s") % e)
-
-
+
+
def onRevert(self, evt):
"""Re-load the current design, losing any changes."""
cf = self.CurrentForm
@@ -1774,10 +1774,10 @@
cf.unlockDisplay()
dui.callAfter(cf.release)
newForm.bringToFront()
-
-
+
+
def onFileExit(self, evt):
- # If a design is being tested, don't exit the whole app,
+ # If a design is being tested, don't exit the whole app,
# just close that window.
af = self.ActiveForm
if af and af.TempForm:
@@ -1796,9 +1796,9 @@
gd = evt.EventObject
if (colNum > -1) and (colNum < gd.ColumnCount):
col = gd.Columns[colNum]
- self.select(col)
-
-
+ self.select(col)
+
+
def onGridHeaderSelected(self, evt):
if self.openingClassXML:
# Not finished creating the controls yet...
@@ -1808,21 +1808,21 @@
if colNum != -1:
col = gd.Columns[colNum]
gd.CurrentColumn = colNum
- self.select(col)
-
-
+ self.select(col)
+
+
def getClassEvents(self, cls):
return self._classEvents.get(cls, [])
-
-
+
+
def getClassMethods(self, cls):
evts = self._classEvents.get(cls, [])
mthds = self._classMethods.get(cls, [])
ret = evts + mthds
ret.sort()
return ret
-
-
+
+
def menuUpdate(self, evt, mb):
mn = evt.menuObject
if mn is mb.getMenu(_("View")):
@@ -1849,17 +1849,17 @@
if doReplace:
item.Caption = cap.replace(old, new)
-
+
def onShowProp(self, evt):
pf = self.PemForm
dabo.ui.callAfter(pf.showPropPage)
-
+
def onShowObjTree(self, evt):
pf = self.PemForm
(41200 bytes were truncated as it was too long for the email (max 40000 bytes.)
_______________________________________________
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/dabo-dev/[EMAIL PROTECTED]