dabo Commit
Revision 1384
Date: 2005-09-27 07:10:43 -0700 (Tue, 27 Sep 2005)
Author: paul
Changed:
U trunk/dabo/lib/datanav/Page.py
U trunk/dabo/lib/reportUtils.py
U trunk/dabo/lib/reportWriter.py
Log:
Fixed some positioning problems with the pageBackground layer of dReportWriter.
I'm now using dReportWriter to print my customer statements - I actually hand-
coded the .rfxml file which was, to say the least, quite tedious.
Improved the Linux branch of previewPDF() to try various popular pdf viewers
instead of relying only on xpdf which is actually one of the least good-
looking choices.
Removed repetitive code from datanav.Page, setting it to now call the
reportUtils.previewPDF() function.
Diff:
Modified: trunk/dabo/lib/datanav/Page.py
===================================================================
--- trunk/dabo/lib/datanav/Page.py 2005-09-26 18:09:58 UTC (rev 1383)
+++ trunk/dabo/lib/datanav/Page.py 2005-09-27 14:10:43 UTC (rev 1384)
@@ -6,6 +6,7 @@
import dabo.dEvents as dEvents
from dabo.dLocalize import _, n_
from dabo.lib.utils import padl
+import dabo.lib.reportUtils as reportUtils
dabo.ui.loadUI("wx")
@@ -548,33 +549,6 @@
self.layout()
- def __onPreview_old(self, evt):
- if self.itemsCreated:
- if self.Form.preview:
- # Just previewing
- dabo.ui.info(message="Not available in preview
mode",
- title = "Preview Mode")
- return
- import wx.html
- html = self.BrowseGrid.getHTML(justStub=False)
- win = wx.html.HtmlEasyPrinting("Dabo Quick Print",
self.Form)
- printData = win.GetPrintData()
- setupData = win.GetPageSetupData()
- #printData.SetPaperId(wx.PAPER_LETTER)
- setupData.SetPaperId(wx.PAPER_LETTER)
- if self.BrowseGrid.GetNumberCols() > 20:
- printData.SetOrientation(wx.LANDSCAPE)
- else:
- printData.SetOrientation(wx.PORTRAIT)
- #setupData.SetMarginTopLeft((17,7))
- #s#etupData.SetMarginBottomRight((17,5))
- # # setupData.SetOrientation(wx.LANDSCAPE)
- win.SetHeader("<B>%s</B>" % (self.Form.Caption,))
- win.SetFooter("<CENTER>Page @PAGENUM@ of
@PAGESCNT@</CENTER>")
- #win.PageSetup()
- win.PreviewText(html)
-
-
def onPreview(self, evt):
if not self.itemsCreated:
return
@@ -616,8 +590,7 @@
if mode == "one":
cursor = (cursor[biz.RowNumber],)
- outputfile = "%s.pdf" % os.tempnam()
- self.Form._tempFiles.append(outputfile)
+ outputfile = reportUtils.getTempFile()
try:
import dabo.dReportWriter as drw
@@ -631,15 +604,7 @@
rw.write()
# Now, preview using the platform's default pdf viewer:
- try:
- os.startfile(outputfile)
- except AttributeError:
- # startfile only available on Windows
- if sys.platform == "darwin":
- os.system("open %s" % outputfile)
- else:
- # on Linux, punt with xpdf:
- os.popen2("xpdf %s" % outputfile)
+ reportUtils.previewPDF(outputfile)
class EditPage(Page):
Modified: trunk/dabo/lib/reportUtils.py
===================================================================
--- trunk/dabo/lib/reportUtils.py 2005-09-26 18:09:58 UTC (rev 1383)
+++ trunk/dabo/lib/reportUtils.py 2005-09-27 14:10:43 UTC (rev 1384)
@@ -29,7 +29,7 @@
getTempFile = tempFileHolder.getTempFile
-def previewPDF(path):
+def previewPDF(path, modal=False):
"""Preview the passed PDF file in the default PDF viewer."""
try:
os.startfile(path)
@@ -38,7 +38,23 @@
if sys.platform == "darwin":
os.system("open %s" % path)
else:
- # on Linux, punt with xpdf:
- os.popen2("xpdf %s" % path)
+ # On Linux, try to find an installed viewer and just
use the first one
+ # found. I just don't know how to reliably get the
default viewer from
+ # the many distros.
+ viewers = ("gpdf", "kpdf", "evince", "acroread",
"xpdf", "firefox",
+ "mozilla-firefox")
+ viewer = None
+ for v in viewers:
+ r = os.system("which %s > /dev/null" % v)
+ if r == 0:
+ viewer = v
+ break
+ if viewer:
+ if modal:
+ sysfunc = os.system
+ else:
+ sysfunc = os.popen2
+ sysfunc("%s %s" % (viewer, path))
+
Modified: trunk/dabo/lib/reportWriter.py
===================================================================
--- trunk/dabo/lib/reportWriter.py 2005-09-26 18:09:58 UTC (rev 1383)
+++ trunk/dabo/lib/reportWriter.py 2005-09-27 14:10:43 UTC (rev 1384)
@@ -614,18 +614,18 @@
if bandDict.has_key("objects"):
for object in bandDict["objects"]:
try:
- x =
self.getPt(eval(object["x"]))
+ x1 =
self.getPt(eval(object["x"]))
except KeyError:
- x = self.default_x
+ x1 = self.default_x
try:
y1 =
self.getPt(eval(object["y"]))
except KeyError:
y1 = self.default_y
- x = ml + x
+ x1 = x + x1
y1 = y + y1
- self.draw(object, (x, y1))
+ self.draw(object, (x1, y1))
return y
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev