daboide Commit
Revision 719
Date: 2006-12-20 07:03:28 -0800 (Wed, 20 Dec 2006)
Author: Ed

Changed:
U   trunk/wizards/AppWizard/AppWizard.py
U   trunk/wizards/AppWizard/spec-main.py.txt

Log:
Reverted the incompatible changes to spec-main.py.txt.

Improved the pathing in AppWizard so that it can more reliably find its source 
files when generating the output.


Diff:
Modified: trunk/wizards/AppWizard/AppWizard.py
===================================================================
--- trunk/wizards/AppWizard/AppWizard.py        2006-12-19 17:29:27 UTC (rev 
718)
+++ trunk/wizards/AppWizard/AppWizard.py        2006-12-20 15:03:28 UTC (rev 
719)
@@ -1,5 +1,7 @@
 #!/usr/bin/env python
-import os, time
+import sys
+import os
+import time
 import traceback
 import dabo
 from dabo.dLocalize import _
@@ -10,9 +12,9 @@
 from dabo.ui.dialogs.Wizard import Wizard
 from dabo.ui import dLabel
 from dabo.lib.connParser import createXML
-from dabo.ui import dTextBox
 from dabo.lib.untabify import process as untabify
 
+
 class HSizer(dabo.ui.dSizer):
        def __init__(self, *args, **kwargs):
                super(HSizer, self).__init__("h", *args, **kwargs)
@@ -163,7 +165,7 @@
                                                Choices=self.supportedDbTypes, 
ValueMode="string")
                        else:
                                pw = (field.lower() == "password")
-                               obj = dTextBox(self, PasswordEntry=pw, 
+                               obj = dabo.ui.dTextBox(self, PasswordEntry=pw, 
                                                Name=("ctl%s" % field), 
SelectOnEntry=True )
                        obj.bindEvent(dabo.dEvents.ValueChanged, 
self.onParmValueChanged)
                        
@@ -604,12 +606,11 @@
                self.Sizer.appendSpacer(5)
                
                lbl = dLabel(self, Caption=_("Enter the name of your app:"))
-               self.txtAppName = dTextBox(self)
+               self.txtAppName = dabo.ui.dTextBox(self)
                hs = HSizer()
                hs.append(lbl)
                hs.appendSpacer(5)
                hs.append1x(self.txtAppName)
-
                self.Sizer.append(hs, "x")
                self.Sizer.appendSpacer(10)
                
@@ -621,7 +622,7 @@
                self.Sizer.append(lbl)
 
                hs = HSizer()
-               self.txtDir = dTextBox(self)
+               self.txtDir = dabo.ui.dTextBox(self)
                ##pkm: Commented this out as it looks awful on Windows.
                ##self.txtDir.FontSize=10
                self.txtDir.Value = ""
@@ -788,7 +789,8 @@
                self.Caption = _("Dabo Application Wizard")
                self.Image = "daboIcon064"
                self.Size = (520, 560)
-
+               
+               self.wizDir = os.getcwd()
                self.tableDict = {}
                self.selectedTables = []
                self.tableRelations = []
@@ -840,7 +842,6 @@
                        rd = self.tableRelationKeys
                        selTb = self.selectedTables
                        ci = self.connectInfo
-                       oldDir = os.getcwd()
                        os.chdir(directory)
                        appName = os.path.split(self.outputDirectory)[-1]
                        self.appKey = ".".join(("dabo", "app", appName))
@@ -858,16 +859,8 @@
                        f.write(self.getMain(ci.Name, selTb[0]))
                        f.close()
 
-                       ## Create a shell script to run the main script:
-                       f = open("./go.sh", "w")
-                       f.write( "cd %s\n" % self.outputDirectory )
-                       f.write( "python %s.py %s\n" % (appName, tableName))
-                       f.close()
-                       import stat
-                       os.chmod('go.sh',stat.S_IRWXU )  ## rwx for user, 
nothing else.
-
                        ## Create the manifest file (for xp theme support):
-                       pth = os.path.join(self.Application.HomeDirectory, 
"spec-main.exe.manifest")
+                       pth = os.path.join(self.wizDir, 
"spec-main.exe.manifest")
                        txt = open(pth).read() % dabo.defaultEncoding
                        open("./%s.exe.manifest" % appName, "w").write(txt)
 
@@ -1003,12 +996,12 @@
                        forms = "".join((forms, """("%s", 
app.ui.Frm%s),\n\t\t\t\t""" % 
                                (table.title(), table.title())))
                forms = "".join((forms, """("-", None),\n\t\t\t\t"""))
-               return open(os.path.join(self.Application.HomeDirectory, 
+               return open(os.path.join(self.wizDir, 
                                "spec-MenFileOpen.py.txt")).read() % locals()
 
 
        def getReportsMenu(self):
-               return open(os.path.join(self.Application.HomeDirectory, 
+               return open(os.path.join(self.wizDir, 
                                "spec-MenReports.py.txt")).read() % locals()
 
        
@@ -1024,7 +1017,7 @@
 """ % locals()
                else:
                        fieldSpecs = ""
-               return open(os.path.join(self.Application.HomeDirectory, 
+               return open(os.path.join(self.wizDir, 
                                "spec-Frm.py.txt")).read() % locals()
 
                                                
@@ -1050,7 +1043,7 @@
                                typ = 
typeConversion.get(fieldDict[field]["type"], "char")
                                colDefs += colSpec % (field, typ, field)
 
-               return open(os.path.join(self.Application.HomeDirectory, 
+               return open(os.path.join(self.wizDir, 
                                "spec-Grd.py.txt")).read() % locals()
 
                                                
@@ -1123,7 +1116,7 @@
                self.itemsCreated = True
 """
 
-               return open(os.path.join(self.Application.HomeDirectory, 
+               return open(os.path.join(self.wizDir, 
                                "spec-PagEdit.py.txt")).read() % locals()
 
                                                
@@ -1245,14 +1238,14 @@
 
                return panel
 """
-               return open(os.path.join(self.Application.HomeDirectory, 
+               return open(os.path.join(self.wizDir, 
                                "spec-PagSelect.py.txt")).read() % locals()
 
                                                
        def getMain(self, dbConnectionDef, table):
                tableName = table.title()
                formOpenString = "\"Frm%s\" % form_name"
-               return open(os.path.join(self.Application.HomeDirectory, 
+               return open(os.path.join(self.wizDir, 
                                "spec-main.py.txt")).read() % locals()
 
 
@@ -1262,38 +1255,38 @@
                                ("ui", ["ui/fieldSpecs.fsxml", 
"ui/relationSpecs.rsxml"]),"""
                else:
                        data_files_fieldspecs = ""
-               return open(os.path.join(self.Application.HomeDirectory, 
+               return open(os.path.join(self.wizDir, 
                                "spec-setup.py.txt")).read() % locals()
 
 
        def getBuildwin(self):
-               return open(os.path.join(self.Application.HomeDirectory, 
+               return open(os.path.join(self.wizDir, 
                                "spec-buildwin.bat")).read() % locals()
 
 
        def getModuleInit_db(self):
-               return open(os.path.join(self.Application.HomeDirectory, 
+               return open(os.path.join(self.wizDir, 
                                "spec-db__init__.py.txt")).read() % locals()
 
 
        def getModuleInit_biz(self, bizImports):
                lines = ["from %s import %s" % (class_, class_) for class_ in 
bizImports]
                bizInit = os.linesep.join(lines)
-               return open(os.path.join(self.Application.HomeDirectory, 
+               return open(os.path.join(self.wizDir, 
                                "spec-biz__init__.py.txt")).read() % locals()
 
 
        def getModuleInit_ui(self, uiImports):
                lines = ["from %s import %s" % (class_, class_) for class_ in 
uiImports]
                uiInit = os.linesep.join(lines)
-               return open(os.path.join(self.Application.HomeDirectory, 
+               return open(os.path.join(self.wizDir, 
                                "spec-ui__init__.py.txt")).read() % locals()
 
 
        def getApp(self, appName):
                appName = appName.title()
                appKey = self.appKey
-               return open(os.path.join(self.Application.HomeDirectory, 
+               return open(os.path.join(self.wizDir, 
                                "spec-App.py.txt")).read() % locals()
 
 
@@ -1306,7 +1299,7 @@
 
 
        def getBaseBizobj(self):
-               return open(os.path.join(self.Application.HomeDirectory, 
+               return open(os.path.join(self.wizDir, 
                                "spec-BizBase.py.txt")).read() % locals()
 
 
@@ -1341,52 +1334,52 @@
                for field in sortedFieldNames:
                        fields += """self.addField("%s.%s as %s")\n\t\t""" % 
(table, field[1], field[1])
                                                
-               return open(os.path.join(self.Application.HomeDirectory, 
+               return open(os.path.join(self.wizDir, 
                                "spec-Biz.py.txt")).read() % locals()
 
 
        def getGrdBase(self):
-               return open(os.path.join(self.Application.HomeDirectory, 
+               return open(os.path.join(self.wizDir, 
                                "spec-GrdBase.py.txt")).read() % locals()
 
 
        def getFrmBase(self):
-               return open(os.path.join(self.Application.HomeDirectory, 
+               return open(os.path.join(self.wizDir, 
                                "spec-FrmBase.py.txt")).read() % locals()
 
 
        def getFrmMain(self):
-               return open(os.path.join(self.Application.HomeDirectory, 
+               return open(os.path.join(self.wizDir, 
                                "spec-FrmMain.py.txt")).read() % locals()
 
 
        def getFrmReportBase(self):
-               return open(os.path.join(self.Application.HomeDirectory, 
+               return open(os.path.join(self.wizDir, 
                                "spec-FrmReportBase.py.txt")).read() % locals()
 
 
        def getFrmReportSample(self):
-               return open(os.path.join(self.Application.HomeDirectory, 
+               return open(os.path.join(self.wizDir, 
                                "spec-FrmReportSample.py.txt")).read() % 
locals()
 
 
        def getPagBase(self, pageName):
-               return open(os.path.join(self.Application.HomeDirectory, 
+               return open(os.path.join(self.wizDir, 
                                "spec-%s.py.txt" % pageName)).read() % locals()
 
 
        def getVersion(self):
-               return open(os.path.join(self.Application.HomeDirectory, 
+               return open(os.path.join(self.wizDir, 
                                "spec-__version__.py.txt")).read() % locals()
 
        def getSampleDataSet(self):
-               return open(os.path.join(self.Application.HomeDirectory, 
+               return open(os.path.join(self.wizDir, 
                                "spec-getSampleDataSet.py.txt")).read() % 
locals()
 
 
        def getSampleReport(self):
                enc = dabo.defaultEncoding
-               return open(os.path.join(self.Application.HomeDirectory, 
+               return open(os.path.join(self.wizDir, 
                                "spec-sampleReport.rfxml")).read() % locals()
 
        def _onConvertTabs(evt):

Modified: trunk/wizards/AppWizard/spec-main.py.txt
===================================================================
--- trunk/wizards/AppWizard/spec-main.py.txt    2006-12-19 17:29:27 UTC (rev 
718)
+++ trunk/wizards/AppWizard/spec-main.py.txt    2006-12-20 15:03:28 UTC (rev 
719)
@@ -39,12 +39,21 @@
 app.dbConnection = app.getConnectionByName("%(dbConnectionDef)s")
 
 # Open one or more of the defined forms. A default one was picked by the app
-# generator. Additionally, if form names were 
+# generator, but you can change that here. Additionally, if form names were 
 # passed on the command line, they will be opened instead of the default one
 # as long as they exist.
-app.default_form = ui.Frm%(tableName)s
-# app.formsToOpen=[ui.FrmMyForm]
-app.startupForms()
+default_form = ui.Frm%(tableName)s
+formsToOpen = []
+form_names = [class_name[3:] for class_name in dir(ui) if class_name[:3] == 
"Frm"]
+for arg in sys.argv[1:]:
+  arg = arg.lower()
+  for form_name in form_names:
+    if arg == form_name.lower():
+      formsToOpen.append(getattr(ui, %(formOpenString)s))
+if not formsToOpen:
+  formsToOpen.append(default_form)
+for frm in formsToOpen:
+  frm(app.MainForm).show()
 
 # Start the application event loop:
 app.start()




_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev

Reply via email to