main logo
Subject: [dabo-dev] dabodesigner Commit 62
Author: noreply .AT. paulmcnett DO.T com
Posted: 2004/04/30 20:46:49
 
View Entire Thread
New Search


dabodesigner Commit
Revision 62
Date: 2004-04-30 18:46:48 -0700 (Fri, 30 Apr 2004)
Author: ed

Log:
Overhauled the onSave() routine to start to generate something remotely
usable. Right now, I'm creating a python script that could be used to run a
form that looks like the one in the designer. Trouble is, it's not quite
working yet. I'm checking it in so that perhaps you might see what's keeping
the form from appearing. It seems to be stuck in the panel's
applyPropValDict() call.


Changed:
U trunk/daboDesigner.py

Diff:
Modified: trunk/daboDesigner.py
===================================================================
--- trunk/daboDesigner.py 2004-04-28 14:11:10 UTC (rev 61)
+++ trunk/daboDesigner.py 2004-05-01 01:46:48 UTC (rev 62)
@@ -164,7 +164,7 @@
self.selecting = False

# Extension used for saving/restoring files
- self.fileExtension = ".dfd"
+ self.fileExtension = ".py"

# Reference for object copy/paste
self.clipObjects = []
@@ -483,17 +483,63 @@


def onSave(self, evt):
- saveList = []
- for ctl in self.custControls:
- saveList.append(ctl.getProps())
- svDlg = wx.FileDialog(None, "Select a file...", wildcard="*.dfd",
+ svDlg = wx.FileDialog(None, "Select a file...", wildcard="*.py",
style=wx.SAVE)
res = svDlg.ShowModal()
if res == wx.ID_OK:
+ outText = self.getSaveTemplate()
+ clsPanel = ""
+ clsControls = ""
+ clsProps = ""
+
+ for ctl in self.custControls:
+ pvTemplate = """\t\t\t"%s" : %s,\n"""
+ clsProps = ""
+ ignoreProps = ["BaseClass", "Bottom", "Class", "Font", "FontFace", "FontInfo",
+ "MousePointer", "Parent", "Right", "SuperClass", "WindowHandle"]
+ pvd = ctl.getPropValDict(ctl)
+ for prop in pvd.keys():
+ if prop in ignoreProps:
+ continue
+
+ sep = "" # Empty String
+ val = pvd[prop]
+ if type(val) in (types.UnicodeType, types.StringType):
+ sep = "'" # Single Quote
+ clsProps += pvTemplate % (prop, sep+self.escapeQt(str(val))+sep)
+
+ # Strip the last comma and newline
+ clsProps = clsProps[:-2]
+
+ clsTemplate = self.getClassTemplate()
+ if ctl is self:
+ super = "dPanel"
+ name = "MainPanel"
+ holder = "%s"
+ else:
+ className = str(ctl.BaseClass).split("'")[1] # split on the single quotes
+ # Get the last element when splitting on the periods.
+ super = className.split(".")[-1:][0]
+ name = ctl.Name
+ holder = ""
+
+ clsDef = clsTemplate % (name, super,ctl.GetWindowStyle(),
+ holder, clsProps)
+
+ if ctl is self:
+ clsPanel = clsDef + "\n\n"
+ else:
+ clsControls += clsDef + "\n\n"
+ clsPanel = clsPanel % ("self.addobject(" + str(super) + ", \"" + name + "\")\n\t\t%s",)
+
+ # Get rid of the last %s in the Panel
+ clsPanel = clsPanel % ""
+ outText = outText % (clsPanel + clsControls)
+
filename = svDlg.GetPath()
if os.path.splitext(filename)[1] != self.fileExtension:
filename += self.fileExtension
- open(filename, "w").write(str(saveList))
+ open(filename, "w").write(outText)
svDlg.Destroy()


@@ -935,10 +981,35 @@
elif dir == "bottom":
obj.Bottom = newval
self.redrawHandles()
-

+
+ def getClassTemplate(self):
+ return """class %s(%s):
+ def __init__(self, style=%s, *args, **kwargs):
+ self.applyPropValDict(self, self.localPropValDict())
+ %s
+ def localPropValDict(self):
+ return {
+%s
+ }"""
+
+
+ def getSaveTemplate(self):
+ return """import wx
+from dabo.ui import *

+%s

+if __name__ == "__main__":
+ app = wx.PySimpleApp()
+ form = dForm(None)
+ form.addObject(MainPanel, "MainPanel")
+ form.Show(True)
+ app.MainLoop()
+"""
+
+
+
class DragHandle(wx.Panel):
""" The class for all the handles used to indicate the selected control
that are dragged to resize the control. It has properties indicating



 
©2004 noreply .AT. paulmcnett .D.O.T com
<-- Prior Message New Search Next Message -->