main logo
Subject: [dabo-dev] daboide Commit 303
Author: Ed Leafe
Posted: 2005/12/30 19:35:10
 
View Entire Thread
New Search


daboide Commit
Revision 303
Date: 2005-12-30 16:35:11 -0800 (Fri, 30 Dec 2005)
Author: ed

Changed:
U trunk/Designer.py
U trunk/DesignerFormMixin.py
U trunk/DesignerMenu.py

Log:
Added the ability to save a short .py file that will run any valid .cdxml file. While this isn't the same as creating a full-blown app, it allows for the first time the ability to create a self-contained, functioning application from the Designer.


Diff:
Modified: trunk/Designer.py
===================================================================
--- trunk/Designer.py 2005-12-30 20:32:48 UTC (rev 302)
+++ trunk/Designer.py 2005-12-31 00:35:11 UTC (rev 303)
@@ -1,5 +1,6 @@
#!/usr/bin/env python
import sys
+import os
import dabo
from dabo.dLocalize import _
import dabo.dEvents as dEvents
@@ -249,7 +250,7 @@
itm = pnl.ControllingSizerItem
sz.setItemProps(itm, sizerInfoDict)
if kids:
- self.recreateChildren(pnl, kids, None, False)
+ self.recreateChildren(pnl, kids, None, False)

elif clsname == "LayoutSizer":
atts = dictStringify(atts)
@@ -435,6 +436,17 @@

def onRunDesign(self, evt):
self.currentForm.onRunDesign(evt)
+
+
+ def onSaveRunnable(self, evt):
+ self.currentForm.onSaveDesign(evt)
+ nm = self.currentForm.getClassFile()
+ fpath, fname = os.path.split(nm)
+ code = self.miniAppTemplate() % fname
+ out = os.path.splitext(nm)[0] + ".py"
+ open(out, "w").write(code)
+ dabo.ui.info("You can run your form by running the file\n%s"
+ % out, title="Runnable App Saved")


def onFileExit(self, evt):
@@ -1244,10 +1256,22 @@
sz.Rows = len(flds)
sz.Columns = 2
sz.setColExpand(True, 1)
- pnl.layout()
-
+ pnl.layout()
self.updateLayout()

+
+ def miniAppTemplate(self):
+ return """import dabo
+
+def main():
+ app = dabo.dApp()
+ app.MainFormClass = "%s"
+ app.start()
+
+if __name__ == '__main__':
+ main()
+"""
+

def _getPalette(self):
noPalette = self._palette is None
@@ -1336,22 +1360,6 @@

def _getPropSht(self):
self._propSheet = self.PemForm.PropSheet
-# noPS = self._propSheet is None
-# if not noPS:
-# # Make sure it's still a live object
-# try:
-# junk = self._propSheet.Visible
-# except dabo.ui.deadObjectException:
-# noPS = True
-# if noPS:
-# frm = self._propSheetForm = dui.dForm(self.currentForm,
-# Caption=_("Properties/Events"))
-# DesignerMenu.mkDesignerMenu(frm)
-# self._propSheet = frm.propSheet = PropSheet(frm)
-# frm.Sizer.append1x(self._propSheet, border=12)
-# frm.layout()
-# frm.refresh()
-# self._propSheet.app = frm.app = self
return self._propSheet



Modified: trunk/DesignerFormMixin.py
===================================================================
--- trunk/DesignerFormMixin.py 2005-12-30 20:32:48 UTC (rev 302)
+++ trunk/DesignerFormMixin.py 2005-12-31 00:35:11 UTC (rev 303)
@@ -138,6 +138,10 @@
self._classMethods = {}


+ def getClassFile(self):
+ return self._classFile
+
+
def onSaveDesign(self, evt):
if not self._classFile:
dlg = dui.dSaveDialog()
@@ -218,7 +222,7 @@

z = [m.lineno for m in modInfo.values()]
z.sort()
- # FInd the index of the first line of this class, and the
+ # Find the index of the first line of this class, and the
# index of the next class.
thisClsLn = inf.lineno
indx = z.index(thisClsLn)

Modified: trunk/DesignerMenu.py
===================================================================
--- trunk/DesignerMenu.py 2005-12-30 20:32:48 UTC (rev 302)
+++ trunk/DesignerMenu.py 2005-12-31 00:35:11 UTC (rev 303)
@@ -55,10 +55,12 @@
fm.prepend(_("&Run...\tCtrl+Shift+R"), bindfunc=app.onRunDesign,
help=_("Test your design by running the form"))
fm.prependSeparator()
+ fm.prepend(_("Save Runnable App"), bindfunc=app.onSaveRunnable,
+ help=_("Create a mini app to run your form"))
+ fm.prepend(_("&Save\tCtrl+S"), bindfunc=app.onSaveDesign,
+ help=_("Save your changes"))
fm.prepend(_("&Open\tCtrl+O"), bindfunc=app.onOpenDesign,
help=_("Open a saved design file"))
- fm.prepend(_("&Save\tCtrl+S"), bindfunc=app.onSaveDesign,
- help=_("Save your changes"))

try:
isMain = parent._isMain





 
©2005 Ed Leafe
<-- Prior Message New Search Next Message -->