dabo Commit
Revision 6408
Date: 2011-02-07 13:06:00 -0800 (Mon, 07 Feb 2011)
Author: Ed
Trac: http://trac.dabodev.com/changeset/6408

Changed:
U   trunk/dabo/ui/dialogs/about.py
U   trunk/dabo/ui/dialogs/htmlAbout.py
U   trunk/dabo/ui/uiwx/__init__.py

Log:
Moved the methods that gather system information out of the About dialogs and 
into the uiwx module. 


Diff:
Modified: trunk/dabo/ui/dialogs/about.py
===================================================================
--- trunk/dabo/ui/dialogs/about.py      2011-02-06 22:36:03 UTC (rev 6407)
+++ trunk/dabo/ui/dialogs/about.py      2011-02-07 21:06:00 UTC (rev 6408)
@@ -12,10 +12,12 @@
                self.Centered = True
                self.Caption = _("About")
 
+
        def initEvents(self):
                self.bindKey("space", self.onClear)
                self.bindKey("enter", self.onClear)
 
+
        def addControls(self):
                pnlBack = dabo.ui.dPanel(self, BackColor="White")
                self.Sizer.append(pnlBack, 1, "x")
@@ -35,7 +37,7 @@
                sz.DefaultBorderTop = sz.DefaultBorderLeft = 
sz.DefaultBorderRight = True
                sz.append(pnlHead, 0, "x")
 
-               eg = dabo.ui.dGrid(pnlBack, DataSet=self.getInfoDataSet(),
+               eg = dabo.ui.dGrid(pnlBack, 
DataSet=dabo.ui.getSystemInfo("dataset"),
                                ShowHeaders=False, ShowCellBorders=False,
                                CellHighlightWidth=0)
                eg.addColumn(dabo.ui.dColumn(eg, Name="Name", DataField="name",
@@ -59,70 +61,20 @@
                hsz.appendSpacer(20)
                hsz.append(btnClose)
                sz.append(hsz, halign="right")
-
                sz.append((0,20))
-
                self.Layout()
                pnlBack.Fit()
 
 
-       def getInfoDataSet(self):
-               """Return Application Information in a sequence of dicts."""
-               # Get all the version info, etc.
-               app = self.Application
-
-               ds = []
-               if app:
-                       plat = app.Platform
-               else:
-                       plat = sys.platform
-               ds.append({"name": "Platform:", "value": plat})
-               ds.append({"name": "Python Version:", "value": "%s on %s"
-                               % (sys.version.split()[0], sys.platform)})
-               if app:
-                       appVersion = app.getAppInfo("appVersion")
-                       appName = app.getAppInfo("appName")
-               else:
-                       appVersion = "?"
-                       appName = "Dabo"
-               ds.append({"name": "Dabo Version:", "value": "Version %s; 
Revision %s"
-                               % (dabo.version["version"], 
dabo.version["revision"])})
-
-#              uiName = dabo.ui.uiType["longName"]
-
-               ds.append({"name": "UI Version:", "value": "%s on %s" % 
(dabo.ui.uiType["version"],
-                               dabo.ui.uiType["platform"])})
-
-               if app:
-                       appSpecific = app.addToAbout()
-                       if appSpecific:
-                               ds.append(appSpecific)
-               return ds
-
-
-       def getInfoString(self):
-               """Return app information as a string."""
-               ds = self.getInfoDataSet()
-               lines = []
-               for r in ds:
-                       lines.append("%s %s" % (r["name"], r["value"]))
-
-               if self.Application.Platform == "Win":
-                       eol = "\r\n"
-               else:
-                       eol = "\n"
-
-               return eol.join(lines)
-
-
        def onCopyInfo(self, evt):
                """Copy the system information to the Clipboard"""
-               self.Application.copyToClipboard(self.getInfoString())
+               self.Application.copyToClipboard(dabo.ui.getSystemInfo())
 
 
        def onClear(self, evt):
                self.Close()
 
+
        def onClose(self, evt=None):
                self.release()
 

Modified: trunk/dabo/ui/dialogs/htmlAbout.py
===================================================================
--- trunk/dabo/ui/dialogs/htmlAbout.py  2011-02-06 22:36:03 UTC (rev 6407)
+++ trunk/dabo/ui/dialogs/htmlAbout.py  2011-02-07 21:06:00 UTC (rev 6408)
@@ -15,10 +15,12 @@
                self.Centered = True
                self.Caption = _("About")
 
+
        def initEvents(self):
                self.bindKey("space", self.onClear)
                self.bindKey("enter", self.onClear)
 
+
        def addControls(self):
                pnlBack = dabo.ui.dPanel(self, BackColor="cornflowerblue")
                self.Sizer.append1x(pnlBack)
@@ -39,10 +41,8 @@
                hsz.appendSpacer(20)
                hsz.append(btnClose)
                sz.append(hsz, halign="right", border=30, borderSides=["right"])
-
                sz.append((0,20))
                self.Layout()
-
                self.htmlBox.Source = self.writeHtmlPage()
 
 
@@ -51,50 +51,11 @@
 
 
        def writeHtmlPage(self):
-               appinfo = self.getInfoString()
+               appinfo = dabo.ui.getSystemInfo("html")
                docstring = self.getAppSpecificString()
                return self.getPageData() % locals()
 
 
-       def getInfoDataSet(self):
-               """Return Application Information in a sequence of dicts."""
-               # Get all the version info, etc.
-               app = self.Application
-
-               ds = []
-               if app:
-                       plat = app.Platform
-               else:
-                       plat = sys.platform
-               ds.append({"name": "Platform:", "value": plat})
-               ds.append({"name": "Python Version:", "value": "%s on %s"
-                               % (sys.version.split()[0], sys.platform)})
-               if app:
-                       appVersion = app.getAppInfo("appVersion")
-                       appName = app.getAppInfo("appName")
-               else:
-                       appVersion = "?"
-                       appName = "Dabo"
-               ds.append({"name": "Dabo Version:", "value": "Version %s; 
Revision %s"
-                               % (dabo.version["version"], 
dabo.version["revision"])})
-
-               ds.append({"name": "UI Version:", "value": "%s on %s" % 
(dabo.ui.uiType["version"],
-                               dabo.ui.uiType["platform"])})
-               return ds
-
-
-       def getInfoString(self, useHTML=True):
-               """Return app information as a string."""
-               ds = self.getInfoDataSet()
-               lines = []
-               for r in ds:
-                       lines.append("%s %s" % (r["name"], r["value"]))
-
-               eol = {True: "<br>\n", False: "\n"}[useHTML]
-
-               return eol.join(lines)
-
-
        def getAppSpecificString(self):
                if self.Application:
                        text = self.Application.addToAbout()
@@ -105,7 +66,7 @@
 
        def onCopyInfo(self, evt):
                """Copy the system information to the Clipboard"""
-               info = self.getInfoString(useHTML=False)
+               info = dabo.ui.getSystemInfo("string")
                appdoc = self.getAppSpecificString()
                self.Application.copyToClipboard("\n\n".join((info, appdoc)))
 
@@ -113,9 +74,11 @@
        def onClear(self, evt):
                self.release()
 
+
        def onClose(self, evt=None):
                self.release()
 
+
        def getPageData(self):
                """Basic Template structure of the About box."""
                return """

Modified: trunk/dabo/ui/uiwx/__init__.py
===================================================================
--- trunk/dabo/ui/uiwx/__init__.py      2011-02-06 22:36:03 UTC (rev 6407)
+++ trunk/dabo/ui/uiwx/__init__.py      2011-02-07 21:06:00 UTC (rev 6408)
@@ -245,7 +245,6 @@
 artConstants["info"] = artConstants.get("information")
 artConstants["file"] = artConstants.get("normalfile")
 
-
 def getUiApp(app, uiAppClass=None, callback=None, forceNew=False):
        """This returns an instance of uiApp. If one is already running, that
        instance is returned. Otherwise, a new instance is created.
@@ -1150,6 +1149,42 @@
        return ret
 
 
+def getSystemInfo(returnType=None):
+       """Return app information in the requested format (can be one
+       of "dataset", "html", or "string" (default).
+       """
+       if returnType is None:
+               returnType = "string"
+       rType = returnType.lower()[0]
+       app = dabo.dAppRef
+       ds = []
+       if app:
+               plat = app.Platform
+       else:
+               plat = sys.platform
+       ds.append({"name": "Platform:", "value": plat})
+       ds.append({"name": "Python Version:", "value": "%s on %s"
+                       % (sys.version.split()[0], sys.platform)})
+       if app:
+               appVersion = app.getAppInfo("appVersion")
+               appName = app.getAppInfo("appName")
+       else:
+               appVersion = "?"
+               appName = "Dabo"
+       ds.append({"name": "Dabo Version:", "value": "Version %s; Revision %s"
+                       % (dabo.version["version"], dabo.version["revision"])})
+       ds.append({"name": "UI Version:", "value": "%s on %s" % 
(dabo.ui.uiType["version"],
+                       dabo.ui.uiType["platform"])})
+       if rType == "d":
+               # Return the dataset
+               return ds
+       lines = []
+       for r in ds:
+               lines.append("%s %s" % (r["name"], r["value"]))
+       eol = {"h": "<br>\n", "s": "\n"}[rType]
+       return eol.join(lines)
+
+
 def sortList(chc, Caption="", ListCaption=""):
        """Wrapper function for the list sorting dialog. Accepts a list,
        and returns the sorted list if the user clicks 'OK'. If they cancel



_______________________________________________
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]

Reply via email to