pythonreports-users Mailing List for PythonReports (Page 2)
Brought to you by:
a1s
You can subscribe to this list here.
2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
|
2012 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(78) |
2013 |
Jan
(15) |
Feb
(12) |
Mar
(25) |
Apr
(2) |
May
(3) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2017 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(2) |
Sep
|
Oct
|
Nov
|
Dec
|
2024 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Werner F. B. <wer...@fr...> - 2013-03-15 16:01:28
|
Hi Alex, On 14/03/2013 19:22, alexander smishlajev wrote: > Werner F. Bruhin wrote, at 14.03.2013 18:47: >> I am still fighting with my card 10 x 15 cm or in inches it is 4 x 6. >> >> It is all layed out correctly now but I can do whatever I want it will >> not print on my cards correctly on a Canon printer. >> >> At this point I am quit sure it has to do with the paper size over >> ridding the custom size. In other words PythonReports passes the page >> size to the pdf writer stuff and the size (width/height) on the report >> level definition are ignored. > http://pythonreports.sourceforge.net/prt.shtml#layout > > width and height attributes are ignored if pagesize is specified. Please find attached a patch to allow not to specify a paper size in the editor. Werner |
From: alexander s. <al...@go...> - 2013-03-14 18:45:30
|
Werner F. Bruhin wrote, at 14.03.2013 18:47: > > I am still fighting with my card 10 x 15 cm or in inches it is 4 x 6. > > It is all layed out correctly now but I can do whatever I want it will > not print on my cards correctly on a Canon printer. > > At this point I am quit sure it has to do with the paper size over > ridding the custom size. In other words PythonReports passes the page > size to the pdf writer stuff and the size (width/height) on the report > level definition are ignored. http://pythonreports.sourceforge.net/prt.shtml#layout width and height attributes are ignored if pagesize is specified. Best wishes, alex. |
From: Werner F. B. <wer...@fr...> - 2013-03-14 16:46:06
|
Hi, I am still fighting with my card 10 x 15 cm or in inches it is 4 x 6. It is all layed out correctly now but I can do whatever I want it will not print on my cards correctly on a Canon printer. At this point I am quit sure it has to do with the paper size over ridding the custom size. In other words PythonReports passes the page size to the pdf writer stuff and the size (width/height) on the report level definition are ignored. <layout height="283" pagesize="B6" width="425"> <style bgcolor="#FFFFFF" color="#000000" font="body" /> <group expr="THIS.id" name="default"> <title> etc etc Is my assumption correct or should it work and I am doing something wrong? Werner |
From: alexander s. <al...@go...> - 2013-03-14 09:29:47
|
On 14.03.2013 11:03, Werner F. Bruhin wrote: > > I am working on reports again and got quit confused that printing from > the preview results are totally incorrect, e.g. Alignment and font size > on the custom form I am doing. > > It works fine for a report which is A4, but the one I am working on is a > 10 x 15 cm card, so none standard size. That is what I meant in the wxPrint module docstring. I tried to find workarounds, but AFAIR success was partial. Tk-based preview works Ok, but of course it would be weird (if at all possible) to use Tk-based window in wx-based application. Another possibility would be to implement HTML renderer for printouts and use wxHtmlWindow to preview output. > What about making use of "wx.lib.pdfviewer" as an alternative to the wx > print preview? Is it cross-platform yet? Last I knew it was based on ActiveX. Anyhow, it would be welcome addition to the package. Please explore the possibility if you are interested. Best wishes, alex. |
From: Werner F. B. <wer...@fr...> - 2013-03-14 09:01:48
|
Hi, I am working on reports again and got quit confused that printing from the preview results are totally incorrect, e.g. Alignment and font size on the custom form I am doing. It works fine for a report which is A4, but the one I am working on is a 10 x 15 cm card, so none standard size. What about making use of "wx.lib.pdfviewer" as an alternative to the wx print preview? Werner |
From: Werner F. B. <wer...@fr...> - 2013-03-07 18:19:23
|
On 07/03/2013 17:13, alexander smishlajev wrote: > On 07.03.2013 18:02, Werner F. Bruhin wrote: >> Is there a good way to suppress the printing of a group header and/or >> footer based on some user defined criteria/parameter? > Printing of sections and body elements may be suppressed by using > "printwhen" attribute of style elements. Great Thanks for the quick response. Werner |
From: alexander s. <al...@go...> - 2013-03-07 16:46:08
|
On 07.03.2013 18:02, Werner F. Bruhin wrote: > > Is there a good way to suppress the printing of a group header and/or > footer based on some user defined criteria/parameter? Printing of sections and body elements may be suppressed by using "printwhen" attribute of style elements. Best wishes, alex. |
From: Werner F. B. <wer...@fr...> - 2013-03-07 16:01:08
|
Hi, Is there a good way to suppress the printing of a group header and/or footer based on some user defined criteria/parameter? If not could a "print expr" be added, if it evaluates to True then print the section otherwise not, with a default of True. Werner |
From: alexander s. <al...@go...> - 2013-02-11 09:43:38
|
On 11.02.2013 11:37, Werner F. Bruhin wrote: > > line 213 in wxPrint.drawImage needs to change to: > _data = prp.Data.get_data(_data) > > line 92 in wxPrint.__init__: > self.imgdata = dict([(_element.get("name"), > prp.Data.get_data(_element)) > > and line 2363 in Builder.build_printout > prp.Data.make_element(_root, data=_image.getdata(), Did it. Thank you very much. Best wishes, alex. |
From: Werner F. B. <wer...@fr...> - 2013-02-11 09:35:39
|
Hi Alex, line 213 in wxPrint.drawImage needs to change to: _data = prp.Data.get_data(_data) line 92 in wxPrint.__init__: self.imgdata = dict([(_element.get("name"), prp.Data.get_data(_element)) and line 2363 in Builder.build_printout prp.Data.make_element(_root, data=_image.getdata(), I.e. in all change "Data" to "prp.Data" If you prefer I can create you a patch later today. At this point the image shows and the editor opens with out problems. Thanks a lot for this, and PythonReports in general. Werner |
From: alexander s. <al...@go...> - 2013-02-11 09:31:00
|
On 11.02.2013 11:25, Werner F. Bruhin wrote: > > NameError: global name 'Data' is not defined > File "c:\Python27\Lib\site-packages\PythonReports\builder.py", line > 1461, in run > return self.build_printout() > File "c:\Python27\Lib\site-packages\PythonReports\builder.py", line > 2363, in build_printout > Data.make_element(_root, data=_image.getdata(), Sorry, this one slipped through. I have checked in a fix. Best wishes, alex. |
From: Werner F. B. <wer...@fr...> - 2013-02-11 09:23:43
|
On 11/02/2013 10:10, alexander smishlajev wrote: > On 11.02.2013 11:03, Werner F. Bruhin wrote: >>> Indeed it is not evaluated. It shouldn't be, with your template >>> contents. Please change the <data> line to <data >>> expr="ru.getRecipeImagePNG(THIS.id)" /> >> Explains why I like to use the designer. > Matter of preference. I find it much easier to understand in XML. I am lousy in remembering syntax. My method is being called now - great, once per recipe, 3 for the test. But then I get this exception: NameError: global name 'Data' is not defined File "c:\dev\twcbv4\twcbsrc\controllers\dreports.py", line 555, in <module> dlg.ShowModal() File "c:\Python27\Lib\site-packages\wx-2.9.5-msw\wx\_windows.py", line 805, in ShowModal return _windows_.Dialog_ShowModal(*args, **kwargs) File "c:\Python27\Lib\site-packages\wx-2.9.5-msw\wx\lib\agw\aquabutton.py", line 434, in OnLeftUp self.Notify() File "c:\Python27\Lib\site-packages\wx-2.9.5-msw\wx\lib\agw\aquabutton.py", line 864, in Notify self.GetEventHandler().ProcessEvent(evt) File "c:\Python27\Lib\site-packages\wx-2.9.5-msw\wx\_core.py", line 4154, in ProcessEvent return _core_.EvtHandler_ProcessEvent(*args, **kwargs) File "c:\dev\twcbv4\twcbsrc\controllers\dreports.py", line 345, in doReportPreview env.report_preview() File "c:\Python27\Lib\site-packages\PythonReports\editor\environment.py", line 263, in report_preview _printout = self.report_build() File "c:\Python27\Lib\site-packages\PythonReports\editor\environment.py", line 245, in report_build return Builder(_template).run(_data) File "c:\Python27\Lib\site-packages\PythonReports\builder.py", line 1461, in run return self.build_printout() File "c:\Python27\Lib\site-packages\PythonReports\builder.py", line 2363, in build_printout Data.make_element(_root, data=_image.getdata(), Best regards and thanks for the quick turn around and the help on this. Werner |
From: alexander s. <al...@go...> - 2013-02-11 09:11:48
|
On 11.02.2013 11:03, Werner F. Bruhin wrote: > >> Indeed it is not evaluated. It shouldn't be, with your template >> contents. Please change the <data> line to <data >> expr="ru.getRecipeImagePNG(THIS.id)" /> > > Explains why I like to use the designer. Matter of preference. I find it much easier to understand in XML. > And I see this exception, not that my breakpoint in the > getRecipeImagePNG is still never hit. > > AttributeError: 'NoneType' object has no attribute 'strip' > "c:\Python27\Lib\site-packages\PythonReports\editor\templateloader.py", > line 222, in load_one_validator > XmlBody(xml_elmnt.text.strip())) Could you try a fresh checkout? I hope I have fixed this error. Best wishes, alex. |
From: Werner F. B. <wer...@fr...> - 2013-02-11 09:02:21
|
On 11/02/2013 09:05, alexander smishlajev wrote: ... > Indeed it is not evaluated. It shouldn't be, with your template > contents. Please change the <data> line to <data > expr="ru.getRecipeImagePNG(THIS.id)" /> Explains why I like to use the designer. I have this for my image: <image type="png"> <box height="30" width="75" x="374" y="50" /> <data expr="ru.getRecipeImagePNG(THIS.id)" /> </image> And I see this exception, not that my breakpoint in the getRecipeImagePNG is still never hit. AttributeError: 'NoneType' object has no attribute 'strip' File "c:\dev\twcbv4\twcbsrc\controllers\dreports.py", line 555, in <module> dlg.ShowModal() File "c:\Python27\Lib\site-packages\wx-2.9.5-msw\wx\_windows.py", line 805, in ShowModal return _windows_.Dialog_ShowModal(*args, **kwargs) File "c:\Python27\Lib\site-packages\wx-2.9.5-msw\wx\lib\agw\aquabutton.py", line 434, in OnLeftUp self.Notify() File "c:\Python27\Lib\site-packages\wx-2.9.5-msw\wx\lib\agw\aquabutton.py", line 864, in Notify self.GetEventHandler().ProcessEvent(evt) File "c:\Python27\Lib\site-packages\wx-2.9.5-msw\wx\_core.py", line 4154, in ProcessEvent return _core_.EvtHandler_ProcessEvent(*args, **kwargs) File "c:\dev\twcbv4\twcbsrc\controllers\dreports.py", line 340, in doReportPreview env.report_open(self.getReportFile()) File "c:\Python27\Lib\site-packages\PythonReports\editor\environment.py", line 201, in report_open templateloader.load_template(_template, _report) File "c:\Python27\Lib\site-packages\PythonReports\editor\templateloader.py", line 23, in load_template load_report(template.getroot(), report) File "c:\Python27\Lib\site-packages\PythonReports\editor\templateloader.py", line 42, in load_report load_groups(_xml_layout, report) File "c:\Python27\Lib\site-packages\PythonReports\editor\templateloader.py", line 92, in load_groups load_group(_xml_group, report) File "c:\Python27\Lib\site-packages\PythonReports\editor\templateloader.py", line 107, in load_group load_section_pair(xml_group, _report_group, (te.Title.tag, te.Summary.tag)) File "c:\Python27\Lib\site-packages\PythonReports\editor\templateloader.py", line 113, in load_section_pair section_pair.get_first()) File "c:\Python27\Lib\site-packages\PythonReports\editor\templateloader.py", line 126, in load_one_of_pair load_section(xml_section, report_section) File "c:\Python27\Lib\site-packages\PythonReports\editor\templateloader.py", line 135, in load_section load_shapes(xml_section, report_section) File "c:\Python27\Lib\site-packages\PythonReports\editor\templateloader.py", line 170, in load_shapes SHAPES_LINK[_section_child.tag]) File "c:\Python27\Lib\site-packages\PythonReports\editor\templateloader.py", line 191, in load_shape load_one_validator(_xml_data, _shape, te.Data) File "c:\Python27\Lib\site-packages\PythonReports\editor\templateloader.py", line 222, in load_one_validator XmlBody(xml_elmnt.text.strip())) Best regards Werner |
From: alexander s. <al...@go...> - 2013-02-11 08:08:36
|
On 11.02.2013 9:54, Werner F. Bruhin wrote: >> >> Try <data expr="ru.getRecipeImagePNG(THIS.id)" /> > > Sorry, to confuse you, the file contains: > > <image type="png"> > <box height="30" width="75" x="374" y="50" /> > <data> expr="ru.getRecipeImagePNG(THIS.id)"</data> > </image> > > When I run it through the debugger (WingIDE) I see at line 92 of fromdata in PILDrivers that the > param "data" contains: > > u'expr="ru.getRecipeImagePNG(THIS.id)"' > > As if the expression has never been evaluated (correct term) Indeed it is not evaluated. It shouldn't be, with your template contents. Please change the <data> line to <data expr="ru.getRecipeImagePNG(THIS.id)" /> Best wishes, alex. |
From: Werner F. B. <wer...@fr...> - 2013-02-11 07:52:33
|
On 11/02/2013 07:49, alexander smishlajev wrote: > On 10.02.2013 22:10, Werner F. Bruhin wrote: >> buf= StringIO.StringIO() >> img.save(buf, format= 'PNG') >> temp = buf.getvalue() >> return temp > This should be Ok. > >> The image element is: >> >> <image type="png"> >> <box height="30" width="75" x="374" y="50" /> >> <data> expr="ru.getRecipeImagePNG(THIS.id)"</data> >> </image> >> >> But I get this traceback: >> File "c:\Python27\Lib\site-packages\PythonReports\PILDrivers.py", line >> 92, in fromdata >> _rv._image = Image.open(StringIO(data)) >> File "c:\Python27\Lib\site-packages\PIL\Image.py", line 1980, in open >> raise IOError("cannot identify image file") >> >> And "data" in fromdata at line 92 is my expression string instead of the >> image data, as if the expression is never "run". >> >> data >> u'expr="ru.getRecipeImagePNG(THIS.id)"' > But of course! Try <data expr="ru.getRecipeImagePNG(THIS.id)" /> Sorry, to confuse you, the file contains: <image type="png"> <box height="30" width="75" x="374" y="50" /> <data> expr="ru.getRecipeImagePNG(THIS.id)"</data> </image> When I run it through the debugger (WingIDE) I see at line 92 of fromdata in PILDrivers that the param "data" contains: u'expr="ru.getRecipeImagePNG(THIS.id)"' As if the expression has never been evaluated (correct term), i.e. my getRecipeImagePNG method is never called. Werner |
From: alexander s. <al...@go...> - 2013-02-11 07:32:51
|
On 10.02.2013 22:10, Werner F. Bruhin wrote: > > buf= StringIO.StringIO() > img.save(buf, format= 'PNG') > temp = buf.getvalue() > return temp This should be Ok. > The image element is: > > <image type="png"> > <box height="30" width="75" x="374" y="50" /> > <data> expr="ru.getRecipeImagePNG(THIS.id)"</data> > </image> > > But I get this traceback: > File "c:\Python27\Lib\site-packages\PythonReports\PILDrivers.py", line > 92, in fromdata > _rv._image = Image.open(StringIO(data)) > File "c:\Python27\Lib\site-packages\PIL\Image.py", line 1980, in open > raise IOError("cannot identify image file") > > And "data" in fromdata at line 92 is my expression string instead of the > image data, as if the expression is never "run". > > data > u'expr="ru.getRecipeImagePNG(THIS.id)"' But of course! Try <data expr="ru.getRecipeImagePNG(THIS.id)" /> Best wishes, alex. |
From: Werner F. B. <wer...@fr...> - 2013-02-10 20:09:27
|
On 10/02/2013 18:16, alexander smishlajev wrote: > On 10.02.2013 15:29, Werner F. Bruhin wrote: >> >> expr gets saved > > I guess you are talking about template designer. Sorry, I didn't > think of checking that. I have modified only report building and > checked PDF formatting. > >> I keep digging through the doc etc, a pointer would obviously be very >> welcome. > > The data returnded from expr is image data - same as would be returned > by reading an image file. Hhm, unless I still do something wrong - quit likely, here is what I get: Changed things to: def getRecipeImagePNG(recid): """ Return a PIL.Image instance of the first image found of type "Recipe finished" (fk_exttype_id=4), or an empty image :param str `recid`: the recipe id :return: Image full path or None """ if recid: app = wx.GetApp() ds = app.ds imgF = app.getDirLocations()[5] with no_autoflush(ds): extfiler = ds.query(db.Extfiler).filter_by(fk_recipe_id = recid, fk_exttype_id = 4).first() if extfiler: img = Image.open(os.path.join(imgF, extfiler.filename)) else: # return a blank one if none is found bDir = os.path.join(wx.GetApp().baseDir, "images") bImg = os.path.join(bDir, "blankImage.jpg") img = Image.open(bImg) buf= StringIO.StringIO() img.save(buf, format= 'PNG') temp = buf.getvalue() return temp The image element is: <image type="png"> <box height="30" width="75" x="374" y="50" /> <data> expr="ru.getRecipeImagePNG(THIS.id)"</data> </image> But I get this traceback: IOError: cannot identify image file File "c:\dev\twcbv4\twcbsrc\controllers\dreports.py", line 555, in <module> dlg.ShowModal() File "c:\Python27\Lib\site-packages\wx-2.9.5-msw\wx\_windows.py", line 805, in ShowModal return _windows_.Dialog_ShowModal(*args, **kwargs) File "c:\Python27\Lib\site-packages\wx-2.9.5-msw\wx\lib\agw\aquabutton.py", line 434, in OnLeftUp self.Notify() File "c:\Python27\Lib\site-packages\wx-2.9.5-msw\wx\lib\agw\aquabutton.py", line 864, in Notify self.GetEventHandler().ProcessEvent(evt) File "c:\Python27\Lib\site-packages\wx-2.9.5-msw\wx\_core.py", line 4154, in ProcessEvent return _core_.EvtHandler_ProcessEvent(*args, **kwargs) File "c:\dev\twcbv4\twcbsrc\controllers\dreports.py", line 345, in doReportPreview env.report_preview() File "c:\Python27\Lib\site-packages\PythonReports\editor\environment.py", line 263, in report_preview _printout = self.report_build() File "c:\Python27\Lib\site-packages\PythonReports\editor\environment.py", line 245, in report_build return Builder(_template).run(_data) File "c:\Python27\Lib\site-packages\PythonReports\builder.py", line 1459, in run self._build(_data_iter, _callback) File "c:\Python27\Lib\site-packages\PythonReports\builder.py", line 1475, in _build self.fill_title() File "c:\Python27\Lib\site-packages\PythonReports\builder.py", line 1634, in fill_title self.start_group(_group) File "c:\Python27\Lib\site-packages\PythonReports\builder.py", line 1852, in start_group self.add_section(self.build_section(_title)) File "c:\Python27\Lib\site-packages\PythonReports\builder.py", line 2067, in build_section _section = Section(self, template, _context) File "c:\Python27\Lib\site-packages\PythonReports\builder.py", line 469, in __init__ self.build(context) File "c:\Python27\Lib\site-packages\PythonReports\builder.py", line 741, in build _element.image = self.builder.image(_item) File "c:\Python27\Lib\site-packages\PythonReports\builder.py", line 1321, in image img_type=_type) File "c:\Python27\Lib\site-packages\PythonReports\PILDrivers.py", line 92, in fromdata _rv._image = Image.open(StringIO(data)) File "c:\Python27\Lib\site-packages\PIL\Image.py", line 1980, in open raise IOError("cannot identify image file") And "data" in fromdata at line 92 is my expression string instead of the image data, as if the expression is never "run". data u'expr="ru.getRecipeImagePNG(THIS.id)"' Hope I am clear and not doing something stupid. Anyhow it is late, I will look at this again tomorrow. Werner |
From: Werner F. B. <wer...@fr...> - 2013-02-10 13:27:30
|
Hi Alex, expr gets saved, I just didn't check _enable, but now I get the following exception, when I have the following for 'image': <image embed="false" type="png"> <box height="30" width="75" x="405" y="35" /> <data expr="ru.getRecipeImage(THIS.id)"></data> </image> I keep digging through the doc etc, a pointer would obviously be very welcome. Werner AttributeError: 'NoneType' object has no attribute 'strip' File "c:\dev\twcbv4\twcbsrc\controllers\dreports.py", line 555, in <module> dlg.ShowModal() File "c:\Python27\Lib\site-packages\wx-2.9.5-msw\wx\_windows.py", line 805, in ShowModal return _windows_.Dialog_ShowModal(*args, **kwargs) File "c:\Python27\Lib\site-packages\wx-2.9.5-msw\wx\lib\agw\aquabutton.py", line 434, in OnLeftUp self.Notify() File "c:\Python27\Lib\site-packages\wx-2.9.5-msw\wx\lib\agw\aquabutton.py", line 864, in Notify self.GetEventHandler().ProcessEvent(evt) File "c:\Python27\Lib\site-packages\wx-2.9.5-msw\wx\_core.py", line 4154, in ProcessEvent return _core_.EvtHandler_ProcessEvent(*args, **kwargs) File "c:\dev\twcbv4\twcbsrc\controllers\dreports.py", line 375, in doReportDesign env.report_open(self.getReportFile()) File "c:\Python27\Lib\site-packages\PythonReports\editor\environment.py", line 201, in report_open templateloader.load_template(_template, _report) File "c:\Python27\Lib\site-packages\PythonReports\editor\templateloader.py", line 23, in load_template load_report(template.getroot(), report) File "c:\Python27\Lib\site-packages\PythonReports\editor\templateloader.py", line 42, in load_report load_groups(_xml_layout, report) File "c:\Python27\Lib\site-packages\PythonReports\editor\templateloader.py", line 92, in load_groups load_group(_xml_group, report) File "c:\Python27\Lib\site-packages\PythonReports\editor\templateloader.py", line 107, in load_group load_section_pair(xml_group, _report_group, (te.Title.tag, te.Summary.tag)) File "c:\Python27\Lib\site-packages\PythonReports\editor\templateloader.py", line 113, in load_section_pair section_pair.get_first()) File "c:\Python27\Lib\site-packages\PythonReports\editor\templateloader.py", line 126, in load_one_of_pair load_section(xml_section, report_section) File "c:\Python27\Lib\site-packages\PythonReports\editor\templateloader.py", line 135, in load_section load_shapes(xml_section, report_section) File "c:\Python27\Lib\site-packages\PythonReports\editor\templateloader.py", line 170, in load_shapes SHAPES_LINK[_section_child.tag]) File "c:\Python27\Lib\site-packages\PythonReports\editor\templateloader.py", line 191, in load_shape load_one_validator(_xml_data, _shape, te.Data) File "c:\Python27\Lib\site-packages\PythonReports\editor\templateloader.py", line 222, in load_one_validator XmlBody(xml_elmnt.text.strip())) |
From: Werner F. B. <wer...@fr...> - 2013-02-10 13:10:05
|
Hi Alex, This time to the list. On 09/02/2013 16:22, alexander smishlajev wrote: ... > I have added the 'expr' attribute to the 'data' element. Hope that > will cover your needs. Not sure, gave it a try but can't get it to work. My getRecipeImage method returns a PIL.Image instance - what should it return? It also looks like data.expr is NOT saved to the template file, i.e. if I save an reopen it the expression is not there. Can you please give me a little pointer on how to use it. When trying the above I see the following exception - probably because I don't use it correctly. Traceback (most recent call last): File "c:\Python27\lib\site-packages\PythonReports\editor\mainmenu.py", line 131, in OnPreview self.app.pyr_editor_env.report_preview() File "c:\Python27\lib\site-packages\PythonReports\editor\environment.py", line 263, in report_preview _printout = self.report_build() File "c:\Python27\lib\site-packages\PythonReports\editor\environment.py", line 245, in report_build return Builder(_template).run(_data) File "c:\Python27\lib\site-packages\PythonReports\builder.py", line 1459, in run self._build(_data_iter, _callback) File "c:\Python27\lib\site-packages\PythonReports\builder.py", line 1475, in _build self.fill_title() File "c:\Python27\lib\site-packages\PythonReports\builder.py", line 1634, in fill_title self.start_group(_group) File "c:\Python27\lib\site-packages\PythonReports\builder.py", line 1852, in start_group self.add_section(self.build_section(_title)) File "c:\Python27\lib\site-packages\PythonReports\builder.py", line 2067, in build_section _section = Section(self, template, _context) File "c:\Python27\lib\site-packages\PythonReports\builder.py", line 469, in __init__ self.build(context) File "c:\Python27\lib\site-packages\PythonReports\builder.py", line 741, in build _element.image = self.builder.image(_item) File "c:\Python27\lib\site-packages\PythonReports\builder.py", line 1313, in image _image = self.image_driver_factory.nullimage() File "c:\Python27\lib\site-packages\PythonReports\drivers.py", line 157, in nullimage return cls.fromdata(PIXEL) TypeError: fromdata() takes at least 3 arguments (2 given) Thanks Werner |
From: Werner F. B. <wer...@fr...> - 2013-01-05 09:39:02
|
On 05/01/2013 09:33, alexander smishlajev wrote: > On 04.01.2013 12:56, Werner F. Bruhin wrote: >>> PythonReports should be found without explicit include. For my other >>> project (no wx part, only reportlab-based builder and pdf output), I use >>> >>> "includes": [ >>> "PythonReports.PILDrivers", >>> "PythonReports.RLDrivers", >> Instead of this I added it to 'packages' which forces the full the >> package to be included: >> packages = ['twcbsrc', 'email', 'amara', 'kinterbasdb', 'setuptools', >> 'sqlalchemy', 'wx.lib.pubsub', 'PythonReports', 'reportlab'] > This pulls in Tkinter which is quite weighty and absolutely unneeded in > your case: you cannot use wx and Tk simultaneously. You are right, didn't show my exclude which I should for other users. excludes = ['_gtkagg', '_tkagg', 'bsddb', 'curses', 'pywin.debugger', 'pywin.debugger.dbgcon', 'pywin.dialogs', 'tcl', 'Tkconstants', 'Tkinter', "_tkinter", 'pydoc', 'doctest', 'test', 'sqlite3' dll_excludes = ['libgdk-win32-2.0-0.dll', 'libgobject-2.0-0.dll', 'tcl84.dll', 'tk84.dll', 'fbclient.dll', 'icudt30.dll', 'icuin30.dll', 'icuuc30.dll', 'mswsock.dll', 'powrprof.dll', 'MSVCP90.dll'] Above is obviously adapted to the needs of my application and each user should adapt it to his/her needs. > >>> I think that img2py will do, too. >> Attached a patch for using img2py > This is checked in. Great, thanks for accepting this patch. Werner |
From: alexander s. <al...@go...> - 2013-01-05 08:34:16
|
On 04.01.2013 12:56, Werner F. Bruhin wrote: > >> PythonReports should be found without explicit include. For my other >> project (no wx part, only reportlab-based builder and pdf output), I use >> >> "includes": [ >> "PythonReports.PILDrivers", >> "PythonReports.RLDrivers", > Instead of this I added it to 'packages' which forces the full the > package to be included: > packages = ['twcbsrc', 'email', 'amara', 'kinterbasdb', 'setuptools', > 'sqlalchemy', 'wx.lib.pubsub', 'PythonReports', 'reportlab'] This pulls in Tkinter which is quite weighty and absolutely unneeded in your case: you cannot use wx and Tk simultaneously. >> I think that img2py will do, too. > Attached a patch for using img2py This is checked in. > FYI, get_resources_dir is also used in "test_system.py" but with an non > existent image - is that to force a fail in the test? No, it was lost when I rearranged subpackages. Best wishes, alex. |
From: alexander s. <al...@go...> - 2013-01-04 08:47:29
|
On 03.01.2013 20:59, Werner F. Bruhin wrote: > > I use py2exe and InnoSetup to generate an installer. > > Updated my setup.py to ensure that PythonReports and reportlab get > included by py2exe by adding them to "packages" option. PythonReports should be found without explicit include. For my other project (no wx part, only reportlab-based builder and pdf output), I use "includes": [ "PythonReports.PILDrivers", "PythonReports.RLDrivers", ], "excludes": [ "tcl", "Tkinter", "_tkinter", ], > However the way images are handled in PythonReports I run into this error: > > 19:39:52: can't open file 'C:\Program Files\TheWineCellarBookV4\lib\library.zip\PythonReports\editor\res\pythonreports.ico' (error 3: le chemin d'accès spécifié est introuvable.) > 19:39:52: No handler found for image type. > > The French text means "access path is not found", however if I check the > library.zip file it does contain the image, but I think > "AddIconFromFile" can't deal with this path (and/or extracting from a > zip archive). No, it can't. The resources are to be packaged as data files, separate from library.zip. I have planned to add a check for ".zip" in module path to editor.utils.get_resource_dir(). In your case, the path would be 'C:\Program Files\TheWineCellarBookV4\lib\res\pythonreports.ico' - with directories up to and including library.zip removed by get_resource_dir(). > To get the images into the library.zip I had to do a hack in the > setup.py to manually update the library.zip. > > The nicest way, in my view, would be to have the images in a resource > file created by imp2py (wxPython tools). That approach should then be > fine regards less of py2exe options/configuration (and should also work > for other freezing tools, cxfrezze etc). I think that img2py will do, too. Best wishes, alex. |
From: Werner F. B. <wer...@fr...> - 2013-01-03 18:58:40
|
Hi, I am at the stage where I like to test my distribution method with PythonReports. I use py2exe and InnoSetup to generate an installer. Updated my setup.py to ensure that PythonReports and reportlab get included by py2exe by adding them to "packages" option. However the way images are handled in PythonReports I run into this error: 19:39:52: can't open file 'C:\Program Files\TheWineCellarBookV4\lib\library.zip\PythonReports\editor\res\pythonreports.ico' (error 3: le chemin d'accès spécifié est introuvable.) 19:39:52: No handler found for image type. The French text means "access path is not found", however if I check the library.zip file it does contain the image, but I think "AddIconFromFile" can't deal with this path (and/or extracting from a zip archive). To get the images into the library.zip I had to do a hack in the setup.py to manually update the library.zip. The nicest way, in my view, would be to have the images in a resource file created by imp2py (wxPython tools). That approach should then be fine regards less of py2exe options/configuration (and should also work for other freezing tools, cxfrezze etc). I would be happy to do a patch for that change if this would be o.k. with you. Best regards Werner |
From: Werner F. B. <wer...@fr...> - 2013-01-02 18:51:20
|
On 02/01/2013 19:38, alexander smishlajev wrote: > Werner F. Bruhin wrote, at 02.01.2013 18:48: >>>> Looking at the image element I don't see how I could do this, if it is >>>> possible could you give me some tips. >>> Sorry, at present there is no way to dynamically compute image file path >>> or bitmap data. >> Not the end of the world, but would definitely be very very nice if you >> can come up with something. > As a workaround, you could create a side-effect function that puts image > files to a constant path, and then call this function via field or > variable expression. Set embed="true" in image element. > > That is a terribly dirty hack, but for now it seems to be the only solution. > >>> That is quite a flaw in the template language. I will have to think of >>> a syntax for such things. So far I've got several ideas, but all of >>> them are either ugly or not backward compatible. >> Is backward compatibility for something like this that important? > There are people that use PythonReports for many years and I do not want > to break all their existing templates if I can avoid that. I call that "forward compatibility", in other words templates created in previous versions will work on future version, but a template created in a newer version will not certainly work or will miss something when run on an older version. > >> Could you create a "dynamic image" element which is ignored by older >> versions? >> >> If you do something can you please allow the program to define what >> image type is used. > I think I will do it like this: > > For all body elements, box, and style elements all attributes will be > allowed to contain an expression to evaluate in context of current data > item. If attribute value is an expression rather than constant, it must > be prefixed with equal sign. E.g.: > > <image file="=picture['file']" type="=picture['type']" /> > > For data elements, I will add attribute 'expr'; same as with fields, > expression evaluation results will take precedence over literal data. > > This change will surely slow down report building for existing templates. Maybe restrict/reduce the change to just "image element" if expect to big slow down. Werner |