Hi Alex,
I am coming back to the preview issue that it is always showing in
Portrait even so report is set to landscape.
Worked out the following:
=== modified file PythonReports/editor/environment.py
--- PythonReports/editor/environment.py 2012-12-21 17:59:03 +0000
+++ PythonReports/editor/environment.py 2012-12-21 18:19:02 +0000
@@ -201,15 +201,32 @@
return None
_template = templatesaver.create_xml_template(_report)
_template.validate()
+ self.report_pageinfo(_template)
return Builder(_template).run(_data)
+ def report_pageinfo(self, _template):
+ """Get page information from template"""
+ layout = _template.find(templateloader.te.Layout.tag)
+ if layout.attrib['pagesize'] == 'A4':
+ self._pageSize = wx.PAPER_A4
+ if layout.attrib['landscape']:
+ self._pageOrientation = wx.LANDSCAPE
+ else:
+ self._pageOrientation = wx.PORTRAIT
+
def report_preview(self):
"""Build report printout and display it in a preview frame"""
_printout = self.report_build()
if not _printout:
return
_printout.validate()
- _preview = wxPrint.Preview(_printout)
+
+ pData = wx.PrintData()
+ pData.SetPaperId(self._pageSize)
+ pData.SetOrientation(self._pageOrientation)
+
+ _preview = wxPrint.Preview(_printout, print_data=pData)
+
if self.filename:
_title = "%s preview" % os.path.basename(self.filename)
else:
But the 'pagesize' needs to be translated and not hard coded as I have done.
Where should I put the translation from the PythonReport
datatypes.PageSize to the wxPython enumeration?
http://wxpython.org/Phoenix/docs/html/PaperSize.enumeration.html#papersize
Have a nice weekend
Werner
|