dabo Commit
Revision 6484
Date: 2011-03-02 03:07:01 -0800 (Wed, 02 Mar 2011)
Author: Werner
Trac: http://trac.dabodev.com/changeset/6484
Changed:
U trunk/ide/wizards/AppWizard/AppWizard.py
U trunk/ide/wizards/AppWizard/spec-App.py.txt
U trunk/ide/wizards/AppWizard/spec-Biz.py.txt
U trunk/ide/wizards/AppWizard/spec-FrmReportBase.py.txt
U trunk/ide/wizards/AppWizard/spec-FrmReportSample.py.txt
U trunk/ide/wizards/AppWizard/spec-Grd.py.txt
U trunk/ide/wizards/AppWizard/spec-PagEdit.py.txt
U trunk/ide/wizards/AppWizard/spec-PagSelect.py.txt
Log:
- Better I18n support and allows to define caption, helptext and tooltip for a
column in the bizobj.
fixes #1407
Diff:
Modified: trunk/ide/wizards/AppWizard/AppWizard.py
===================================================================
--- trunk/ide/wizards/AppWizard/AppWizard.py 2011-02-28 18:55:03 UTC (rev
6483)
+++ trunk/ide/wizards/AppWizard/AppWizard.py 2011-03-02 11:07:01 UTC (rev
6484)
@@ -582,6 +582,7 @@
self.wizDir = self.Application.HomeDirectory
else:
self.wizDir = defaultDirectory
+
self.tableDict = {}
self.selectedTables = []
self.outputDirectory = ""
@@ -810,20 +811,22 @@
def getGrd(self, table):
tableName = getSafeTableName(table)
+ datasource = table
colDefs = ""
fieldDict = self.tableDict[table]["fields"]
colDefs += """
# Delete or comment out any columns you don't want..."""
colSpec = """
- self.addColumn(dabo.ui.dColumn(self, DataField="%s",
Caption="%s",
+ self.addColumn(dabo.ui.dColumn(self, DataField="%s",
+ Caption=biz.getColCaption("%s"),
Sortable=True, Searchable=True, Editable=False))
"""
sortedFieldNames = self.getSortedFieldNames(fieldDict)
for tup in sortedFieldNames:
field = tup[1]
- colDefs += colSpec % (field, field.title())
+ colDefs += colSpec % (field, field)
return open(os.path.join(self.wizDir,
"spec-Grd.py.txt")).read() % locals()
@@ -831,6 +834,7 @@
def getPagEdit(self, table):
tableName = getSafeTableName(table)
+ datasource = table
createItems = ""
fieldDict = self.tableDict[table]["fields"]
@@ -845,9 +849,13 @@
itemSpec = """
## Field %(table)s.%(fieldName)s
- label = dabo.ui.dLabel(self, NameBase="lbl%(fieldName)s",
Caption="%(labelCaption)s")
+ label = dabo.ui.dLabel(self, NameBase="lbl%(fieldName)s",
+
Caption=biz.getColCaption("%(labelCaption)s"))
objectRef = %(classRef)s(self, NameBase="%(fieldName)s",
- DataSource="%(table)s",
DataField="%(fieldName)s"%(ctrlCap)s)
+ DataSource="%(table)s",
DataField="%(fieldName)s"%(ctrlCap)s,
+ ToolTipText=biz.getColToolTip("%(fieldName)s"),
+ HelpText=biz.getColHelpText("%(fieldName)s")
+)
gs.append(label, alignment=("top", "right") )%(memo_sizer)s
gs.append(objectRef, "expand")
@@ -865,7 +873,7 @@
elif fieldType in ["bool",]:
classRef = "dabo.ui.dCheckBox"
labelCaption = ""
- ctrlCap = ', Caption="%s"' % fieldName
+ ctrlCap = ', Caption=biz.getColCaption("%s")' %
fieldName
elif fieldType in ["date",]:
#pkm: temporary: dDateTextBox is misbehaving
still. So, until we get
# it figured out, change the type of
control used for date editing
@@ -909,6 +917,7 @@
def getSelectOptionsPanel(self):
"""Return the panel to contain all the select options."""
+ biz = self.Form.getBizobj()
panel = dabo.ui.dPanel(self)
gsz = dabo.ui.dGridSizer(VGap=5, HGap=10)
gsz.MaxCols = 3
@@ -928,7 +937,7 @@
## Field %(table)s.%(fieldName)s
##
lbl = SortLabel(panel)
- lbl.Caption = "%(fieldName)s:"
+ lbl.Caption = biz.getColCaption("%(fieldName)s")
lbl.relatedDataField = "%(fieldName)s"
# Automatically get the selector options based on the field
type:
@@ -983,7 +992,7 @@
gsz.append(limTxt)
# Custom SQL checkbox:
- chkCustomSQL = dabo.ui.dCheckBox(panel, Caption="Use Custom
SQL")
+ chkCustomSQL = dabo.ui.dCheckBox(panel, Caption=_("Use Custom
SQL"))
chkCustomSQL.bindEvent(dEvents.Hit, self.onCustomSQL)
gsz.append(chkCustomSQL)
Modified: trunk/ide/wizards/AppWizard/spec-App.py.txt
===================================================================
--- trunk/ide/wizards/AppWizard/spec-App.py.txt 2011-02-28 18:55:03 UTC (rev
6483)
+++ trunk/ide/wizards/AppWizard/spec-App.py.txt 2011-03-02 11:07:01 UTC (rev
6484)
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
import dabo
+from dabo.dLocalize import _
from __version__ import version
@@ -20,7 +21,7 @@
self.setAppInfo("companyEmail", "Your company email")
self.setAppInfo("companyUrl", "Your company url")
- self.setAppInfo("appDescription", "Describe your app.")
+ self.setAppInfo("appDescription", _("Describe your app."))
## Information about the developer of the software:
self.setAppInfo("authorName", "Your name")
Modified: trunk/ide/wizards/AppWizard/spec-Biz.py.txt
===================================================================
--- trunk/ide/wizards/AppWizard/spec-Biz.py.txt 2011-02-28 18:55:03 UTC (rev
6483)
+++ trunk/ide/wizards/AppWizard/spec-Biz.py.txt 2011-03-02 11:07:01 UTC (rev
6484)
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
+from dabo.dLocalize import _
from Base import Base
@@ -11,6 +12,13 @@
self.DataSource = "%(table)s"
self.KeyField = %(pkField)s
+ # dict in the form of
+ # {'colname': [_('caption for colname'),
+ # _('tooltip for colname'),
+ # _('helptext> for colname')]}
+
+ self.ColTextsDict = {}
+
# Setting the DataStructure explicitly here is optional, but
recommended as
# it will keep Dabo from interpreting field types from the
backend every
# time. It lets you specify what types you expect which fields
to be. Also,
@@ -43,3 +51,27 @@
self.addFrom("%(tableNameQt)s")
self.setLimitClause("500")
self.addFieldsFromDataStructure()
+
+ def getColCaption(self, column):
+ # if self.ColTextsDict is defined get the text from there,
otherwise
+ # just return the column name
+ if self.ColTextsDict.has_key(column):
+ return self.ColTextsDict[column][0]
+ else:
+ return column
+
+ def getColToolTip(self, column):
+ # if self.ColTextsDict is defined get the text from there,
otherwise
+ # just return the column name
+ if self.ColTextsDict.has_key(column):
+ return self.ColTextsDict[column][1]
+ else:
+ return column
+
+ def getColHelpText(self, column):
+ # if self.ColTextsDict is defined get the text from there,
otherwise
+ # just return the column name
+ if self.ColTextsDict.has_key(column):
+ return self.ColTextsDict[column][2]
+ else:
+ return column
Modified: trunk/ide/wizards/AppWizard/spec-FrmReportBase.py.txt
===================================================================
--- trunk/ide/wizards/AppWizard/spec-FrmReportBase.py.txt 2011-02-28
18:55:03 UTC (rev 6483)
+++ trunk/ide/wizards/AppWizard/spec-FrmReportBase.py.txt 2011-03-02
11:07:01 UTC (rev 6484)
@@ -1,5 +1,7 @@
# -*- coding: utf-8 -*-
+from dabo.dLocalize import _
+
import dabo.ui
import dabo.lib.reportUtils as reportUtils
@@ -25,9 +27,9 @@
def addControls(self):
hs = dabo.ui.dSizer("h")
- hs.append(dabo.ui.dButton(self, Caption="Preview",
RegID="butPreview"),
+ hs.append(dabo.ui.dButton(self, Caption=_("Preview"),
RegID="butPreview"),
alignment="right", border=self.SizerBorder)
- hs.append(dabo.ui.dButton(self, Caption="Print",
RegID="butPrint"),
+ hs.append(dabo.ui.dButton(self, Caption=_("Print"),
RegID="butPrint"),
alignment="right", border=self.SizerBorder)
self.Sizer.append(hs, alignment="bottom",
border=self.SizerBorder)
Modified: trunk/ide/wizards/AppWizard/spec-FrmReportSample.py.txt
===================================================================
--- trunk/ide/wizards/AppWizard/spec-FrmReportSample.py.txt 2011-02-28
18:55:03 UTC (rev 6483)
+++ trunk/ide/wizards/AppWizard/spec-FrmReportSample.py.txt 2011-03-02
11:07:01 UTC (rev 6484)
@@ -7,6 +7,7 @@
import datetime
import os
+from dabo.dLocalize import _
import dabo.ui
from FrmReportBase import FrmReportBase
@@ -15,7 +16,7 @@
def initProperties(self):
app = self.Application
- self.ReportName = "Sample Report"
+ self.ReportName = _("Sample Report")
self.super()
self.ReportForm = os.path.join(app.HomeDirectory,
"reports/sampleReport.rfxml")
self.DataSetFunction = app.db.getSampleDataSet
Modified: trunk/ide/wizards/AppWizard/spec-Grd.py.txt
===================================================================
--- trunk/ide/wizards/AppWizard/spec-Grd.py.txt 2011-02-28 18:55:03 UTC (rev
6483)
+++ trunk/ide/wizards/AppWizard/spec-Grd.py.txt 2011-03-02 11:07:01 UTC (rev
6484)
@@ -8,8 +8,10 @@
class Grd%(tableName)s(GrdBase):
- def afterInit(self):
+ def afterInitAll(self):
self.super()
+ biz = self.Form.getBizobj("%(datasource)s")
+
%(colDefs)s
Modified: trunk/ide/wizards/AppWizard/spec-PagEdit.py.txt
===================================================================
--- trunk/ide/wizards/AppWizard/spec-PagEdit.py.txt 2011-02-28 18:55:03 UTC
(rev 6483)
+++ trunk/ide/wizards/AppWizard/spec-PagEdit.py.txt 2011-03-02 11:07:01 UTC
(rev 6484)
@@ -10,6 +10,8 @@
def createItems(self):
"""Called by the datanav framework, when it is time to create
the controls."""
+
+ biz = self.Form.getBizobj("%(datasource)s")
%(createItems)s
self.super()
Modified: trunk/ide/wizards/AppWizard/spec-PagSelect.py.txt
===================================================================
--- trunk/ide/wizards/AppWizard/spec-PagSelect.py.txt 2011-02-28 18:55:03 UTC
(rev 6483)
+++ trunk/ide/wizards/AppWizard/spec-PagSelect.py.txt 2011-03-02 11:07:01 UTC
(rev 6484)
@@ -12,7 +12,7 @@
class PagSelect%(tableName)s(PagSelectBase):
-%(selectOptionsPanel)s
+ %(selectOptionsPanel)s
if __name__ == "__main__":
_______________________________________________
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/[email protected]