daboide Commit
Revision 217
Date: 2005-10-30 16:50:36 -0800 (Sun, 30 Oct 2005)
Author: paul
Changed:
U trunk/wizards/AppWizardX/AppWizard.py
U trunk/wizards/AppWizardX/spec-FrmBase.py
U trunk/wizards/AppWizardX/spec-MenFileOpen.py
A trunk/wizards/AppWizardX/spec-MenReports.py
Log:
Added a reports menu to the wizard-generated applications. Added code to the
generated application to move the Quick Report option from the Actions menu
over to the Reports menu.
Also added some comments and reorganized some of the generated code.
Diff:
Modified: trunk/wizards/AppWizardX/AppWizard.py
===================================================================
--- trunk/wizards/AppWizardX/AppWizard.py 2005-10-30 21:34:50 UTC (rev
216)
+++ trunk/wizards/AppWizardX/AppWizard.py 2005-10-31 00:50:36 UTC (rev
217)
@@ -745,12 +745,16 @@
f.write(relationSpecs(rd))
f.close()
- ## file|open menu:
+ ## File|Open menu:
f = open("./MenFileOpen.py", "w")
f.write(self.getFileOpenMenu(selTb))
f.close()
-
+ ## Reports menu:
+ f = open("./MenReports.py", "w")
+ f.write(self.getReportsMenu())
+ f.close()
+
## base page:
open("./PagBase.py", "w").write(self.getPagBase())
@@ -781,6 +785,11 @@
return open(os.path.join(self.Application.HomeDirectory,
"spec-MenFileOpen.py")).read() % locals()
+
+ def getReportsMenu(self):
+ return open(os.path.join(self.Application.HomeDirectory,
+ "spec-MenReports.py")).read() % locals()
+
def getForm(self, table):
tableName = table.title()
Modified: trunk/wizards/AppWizardX/spec-FrmBase.py
===================================================================
--- trunk/wizards/AppWizardX/spec-FrmBase.py 2005-10-30 21:34:50 UTC (rev
216)
+++ trunk/wizards/AppWizardX/spec-FrmBase.py 2005-10-31 00:50:36 UTC (rev
217)
@@ -5,15 +5,42 @@
class FrmBase(datanav.Form):
def initProperties(self):
+ # Setting RequeryOnLoad to True will result in an automatic
requery upon
+ # form load, which may be appropriate for your app (if it is
reasonably
+ # certain that the dataset will be small no matter what).
self.RequeryOnLoad = False
- def afterSetMenuBar(self):
+ def setupMenu(self):
+ FrmBase.doDefault()
self.fillFileOpenMenu()
+ self.fillReportsMenu()
def fillFileOpenMenu(self):
+ """Add the File|Open menu, with menu items for opening each
form."""
app = self.Application
fileMenu = self.MenuBar.getMenu("File")
fileMenu.prependMenu(app.ui.MenFileOpen(fileMenu))
+
+ def fillReportsMenu(self):
+ """Add the Reports menu."""
+ app = self.Application
+ menReports = app.ui.MenReports()
+
+ # We want the reports menu right after the Actions menu:
+ idx = self.MenuBar.getMenuIndex("Actions")
+ if idx is None:
+ # punt:
+ idx = 3
+ idx += 1
+ self.MenuBar.insertMenu(idx, menReports)
+
+ # The datanav form puts a Quick Report option at the end of the
Actions
+ # menu, but because our wizard code has placed a Quick Report
option at
+ # the top of the Reports menu, let's remove the one on the
Actions menu.
+ menu = self.MenuBar.getMenu("Actions")
+ idx = menu.getItemIndex("Quick Report")
+ if idx is not None:
+ menu.remove(idx)
Modified: trunk/wizards/AppWizardX/spec-MenFileOpen.py
===================================================================
--- trunk/wizards/AppWizardX/spec-MenFileOpen.py 2005-10-30 21:34:50 UTC
(rev 216)
+++ trunk/wizards/AppWizardX/spec-MenFileOpen.py 2005-10-31 00:50:36 UTC
(rev 217)
@@ -4,16 +4,19 @@
class MenFileOpen(dabo.ui.dMenu):
- def afterInit(self):
+ def initProperties(self):
self.Caption = "&Open\tCtrl+O"
self.HelpText = "Open a module"
+
+ def afterInit(self):
+ app = self.Application
+ autoHotKeys = True
+
# Define the forms you want in your open menu here. Insert a
("-", None)
# tuple and the code below will insert a separator in its
place. Explicitly
# set up which character has the hotkey by adding a & in front
of it and
# by turning off the autoHotKeys flag.
- autoHotKeys = True
- app = self.Application
forms = (%(forms)s)
Added: trunk/wizards/AppWizardX/spec-MenReports.py
===================================================================
--- trunk/wizards/AppWizardX/spec-MenReports.py 2005-10-30 21:34:50 UTC (rev
216)
+++ trunk/wizards/AppWizardX/spec-MenReports.py 2005-10-31 00:50:36 UTC (rev
217)
@@ -0,0 +1,54 @@
+import dabo
+import dabo.dEvents as dEvents
+
+
+class MenReports(dabo.ui.dMenu):
+
+ def initProperties(self):
+ self.Caption = "Re&ports"
+ self.HelpText = "Run a report to screen or printer"
+
+
+ def afterInit(self):
+ app = self.Application
+ autoHotKeys = False
+
+ # Insert the Quick Report option at the top:
+ itm = dabo.ui.dMenuItem(self, Caption="Quick Report")
+ itm.bindEvent(dEvents.Hit, self.onQuickReport)
+ self.appendItem(itm)
+ self.appendSeparator()
+
+ # Define the forms you want in your report menu here. Insert a
("-", None)
+ # tuple and the code below will insert a separator in its
place. Explicitly
+ # set up which character has the hotkey by adding a & in front
of it and
+ # by turning off the autoHotKeys flag. eg:
+ # forms = (("&Invoices",
app.ui.FrmReportInvoices),
+ # ("&Statements",
app.ui.FrmReportStatements),)
+ forms = ()
+
+ for form in forms:
+ caption = form[0]
+ if caption == "-":
+ # insert separator instead:
+ self.appendSeparator()
+ else:
+ if autoHotKeys and "&" not in caption:
+ caption = "&%%s" %% caption
+ plainCaption = caption.replace("&", "")
+ itm = dabo.ui.dMenuItem(self, Caption=caption,
+ HelpText="Run the %%s report"
%% plainCaption,
+ Tag=form[1])
+ itm.bindEvent(dEvents.Hit, self.openForm)
+ self.appendItem(itm)
+
+
+ def openForm(self, evt):
+ app = self.Application
+ mainForm = app.MainForm
+ frm = evt.EventObject.Tag(mainForm)
+ frm.show()
+ frm.release()
+
+ def onQuickReport(self, evt):
+ self.Form.onQuickReport(evt)
Property changes on: trunk/wizards/AppWizardX/spec-MenReports.py
___________________________________________________________________
Name: svn:eol-style
+ native
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev