pythonreports-users Mailing List for PythonReports (Page 4)
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...> - 2012-12-22 08:47:17
|
On 22/12/2012 08:39, alexander smishlajev wrote: > On 21.12.2012 20:16, Werner F. Bruhin wrote: >> Attached a patch to show fonts in the list as e.g.: >> >> body (8biu:Arial) >> >> and styles in the list as e.g.: >> >> style 2 - body > Thank you. > > I have a question: may the computation of list titles be done by the > values themselves? ListPropertyDialog does not seem to be the right > place for this. I had tried to do it in class ListElement and replace how self.name is generated in there, but I hit a wall in not being able to figure out how to get at the attributes value (shows my lack of Python knowhow:-( ). How do I get at if bold is true or false? attributes['bold'] (<class 'PythonReports.datatypes.Boolean'>, <Boolean: false>) And how to get at the typeface name at that point? attributes['typeface'] (<class 'PythonReports.datatypes.String'>, <PythonReports.datatypes.REQUIRED object at 0x05D0CF70>) Werner |
From: Werner F. B. <wer...@fr...> - 2012-12-22 08:28:44
|
Hi Alex, Attached an updated patch with the size to wxSize translation. I haven't figured out how to handle custom sizes, i.e. all the ones with wx.PAPER_NONE. Have a nice weekend Werner P.S. There are a few standard sizes "B3" and "B6" in the wx enumeration, reported it on the wx list. |
From: alexander s. <al...@go...> - 2012-12-22 07:40:30
|
On 21.12.2012 20:16, Werner F. Bruhin wrote: > > Attached a patch to show fonts in the list as e.g.: > > body (8biu:Arial) > > and styles in the list as e.g.: > > style 2 - body Thank you. I have a question: may the computation of list titles be done by the values themselves? ListPropertyDialog does not seem to be the right place for this. Best wishes, alex. |
From: Werner F. B. <wer...@fr...> - 2012-12-21 18:25:59
|
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 |
From: Werner F. B. <wer...@fr...> - 2012-12-21 18:15:02
|
Hi Den, Attached a clean patch for the split of application into two files. To be able to set the "data" without having to go via the shell I added a property "report_data" to environment.py, hope that is acceptable. Werner |
From: Werner F. B. <wer...@fr...> - 2012-12-21 18:14:54
|
Hi Alex, Attached a patch to show fonts in the list as e.g.: body (8biu:Arial) and styles in the list as e.g.: style 2 - body Werner |
From: alexander s. <al...@go...> - 2012-12-21 07:17:01
|
On 21.12.2012 9:10, Werner F. Bruhin wrote: > >>> File "c:\Python27\lib\xml\etree\ElementTree.py", line 350, in getchildren >>> DeprecationWarning, stacklevel=2 >>> DeprecationWarning: This method will be removed in future versions. Use >>> 'list(elem)' or iteration over elem instead. >> Right. That's error, and it has to be fixed. > I don't know/see how to fix it. Please try this: http://pythonreports.bzr.sourceforge.net/bzr/pythonreports/revision/236 > Will you report it to ElementTree? No. Best wishes, alex. |
From: Werner F. B. <wer...@fr...> - 2012-12-21 07:09:41
|
Hi Alex, On 20/12/2012 20:54, alexander smishlajev wrote: > Werner F. Bruhin wrote, at 20.12.2012 20:57: ... >> This is the traceback I see in WingIDE: >> >> Error saving template file This method will be removed in future >> versions. Use 'list(elem)' or iteration over elem instead. >> Traceback (most recent call last): >> File "c:\Python27\lib\site-packages\PythonReports\editor\toolbar.py", >> line 47, in OnSave >> self.app.pyr_editor_env.report_save() >> >> File "c:\Python27\lib\site-packages\PythonReports\datatypes.py", line >> 1070, in writexml >> for _child in element.getchildren(): >> File "c:\Python27\lib\xml\etree\ElementTree.py", line 350, in getchildren >> DeprecationWarning, stacklevel=2 >> DeprecationWarning: This method will be removed in future versions. Use >> 'list(elem)' or iteration over elem instead. > Right. That's error, and it has to be fixed. I don't know/see how to fix it. Will you report it to ElementTree? I am o.k. with just doing the "warnings.simplefilter("ignore")" just before calling the designer and then I reset the warnings when it is closing. Have a good weekend Werner |
From: alexander s. <al...@go...> - 2012-12-21 06:58:17
|
Werner F. Bruhin wrote, at 20.12.2012 20:57: > >>> Error saving template file This method will be removed in future >>> versions. Use 'list(elem)' or iteration over elem instead. >> >> You mean, warning; this shouldn't be error. > > It is a warning, but it damages the file I try to save, i.e. it has "0" > bytes after, if I try to reopen it I get "Invalid template file". Don't > understand why, still searching. > > This is the traceback I see in WingIDE: > > Error saving template file This method will be removed in future > versions. Use 'list(elem)' or iteration over elem instead. > Traceback (most recent call last): > File "c:\Python27\lib\site-packages\PythonReports\editor\toolbar.py", > line 47, in OnSave > self.app.pyr_editor_env.report_save() > File "c:\Python27\lib\site-packages\PythonReports\datatypes.py", line > 1070, in writexml > for _child in element.getchildren(): > File "c:\Python27\lib\xml\etree\ElementTree.py", line 350, in getchildren > DeprecationWarning, stacklevel=2 > DeprecationWarning: This method will be removed in future versions. Use > 'list(elem)' or iteration over elem instead. Right. That's error, and it has to be fixed. >> Sorry, no. The iterator interface is not documented prior to 2.7, and I >> also do not see it in the xml/etree/ElementTree.py source. And I don't >> grok how the list() trick could possibly work. > > I was going to suggest "if sys.version_info > 2.7:" but if the list > trick won't work then that is not an option. I mean, converting to list shouldn't work without iterator. Adding a check for Python version is an obvious work around, but that would be quite ugly thing to add in five places where .getchildren() is needed. Best wishes, alex. |
From: Werner F. B. <wer...@fr...> - 2012-12-20 18:56:34
|
Hi Alex, (send again, but to list this time) On 20/12/2012 18:41, alexander smishlajev wrote: > Werner F. Bruhin wrote, at 20.12.2012 18:29: >> Error saving template file This method will be removed in future >> versions. Use 'list(elem)' or iteration over elem instead. > You mean, warning; this shouldn't be error. It is a warning, but it damages the file I try to save, i.e. it has "0" bytes after, if I try to reopen it I get "Invalid template file". Don't understand why, still searching. This is the traceback I see in WingIDE: Error saving template file This method will be removed in future versions. Use 'list(elem)' or iteration over elem instead. Traceback (most recent call last): File "c:\Python27\lib\site-packages\PythonReports\editor\toolbar.py", line 47, in OnSave self.app.pyr_editor_env.report_save() File "c:\Python27\lib\site-packages\PythonReports\editor\environment.py", line 192, in report_save self.report_save_file(self.filename) File "c:\Python27\lib\site-packages\PythonReports\editor\environment.py", line 181, in report_save_file templatesaver.save_template_file(_report, filename) File "c:\Python27\lib\site-packages\PythonReports\editor\templatesaver.py", line 67, in save_template_file _xml_template.write(file_name) File "c:\Python27\lib\site-packages\PythonReports\datatypes.py", line 1315, in write self.root_validator.writexml(file, self._root, encoding) File "c:\Python27\lib\site-packages\PythonReports\datatypes.py", line 1070, in writexml for _child in element.getchildren(): File "c:\Python27\lib\xml\etree\ElementTree.py", line 350, in getchildren DeprecationWarning, stacklevel=2 DeprecationWarning: This method will be removed in future versions. Use 'list(elem)' or iteration over elem instead. I tried using catch_warnings, but I must do something wrong as it still hits the error. with warnings.catch_warnings(): warnings.simplefilter("ignore") self.env = EditorEnvironment(EditorForm(None)) > Sorry, no. The iterator interface is not documented prior to 2.7, and I > also do not see it in the xml/etree/ElementTree.py source. And I don't > grok how the list() trick could possibly work. I was going to suggest "if sys.version_info > 2.7:" but if the list trick won't work then that is not an option. Do you see what I am doing wrong with the catch_warnings? > > There is getiterator() method, but it returns something completely > different... > > So, unless there is solution acceptable for 2.4 the easiest way would be > to ignore this warning (maybe add a filtering code to start-up script). > > I don't expect the deprecated method disappear until the end of Python2 > life time, and for Python3 there is no wx. There are wxPython Phoenix builds:) for Python 3.x, but yes they are not yet ready for real usage. See you Werner |
From: Werner F. B. <wer...@fr...> - 2012-12-20 18:55:54
|
Found it how to catch, can't use "with", so this does the trick for me: warnings.simplefilter("ignore") self.env = EditorEnvironment(EditorForm(None)) Werner |
From: alexander s. <al...@go...> - 2012-12-20 17:43:04
|
Werner F. Bruhin wrote, at 20.12.2012 18:29: > > Error saving template file This method will be removed in future > versions. Use 'list(elem)' or iteration over elem instead. You mean, warning; this shouldn't be error. > I see the above for: > > builder.find_layout_parents > datatypes.writexml > > In both cases I could just change from: > > for _child in element.getchildren(): > > to: > > for _child in element: > > Is this fine or do you prefer a different fix? Sorry, no. The iterator interface is not documented prior to 2.7, and I also do not see it in the xml/etree/ElementTree.py source. And I don't grok how the list() trick could possibly work. There is getiterator() method, but it returns something completely different... So, unless there is solution acceptable for 2.4 the easiest way would be to ignore this warning (maybe add a filtering code to start-up script). I don't expect the deprecated method disappear until the end of Python2 life time, and for Python3 there is no wx. Best wishes, alex. |
From: Werner F. B. <wer...@fr...> - 2012-12-20 16:27:58
|
Hi, Before I forget about this one. Error saving template file This method will be removed in future versions. Use 'list(elem)' or iteration over elem instead. I see the above for: builder.find_layout_parents datatypes.writexml In both cases I could just change from: for _child in element.getchildren(): to: for _child in element: Is this fine or do you prefer a different fix? There are some more calls to et.getchildren which I didn't hit, where I think the "list(elem)" solution should be used. Werner |
From: Werner F. B. <wer...@fr...> - 2012-12-20 16:25:45
|
Hi Den, I made the changes as per your suggestion and so far it works out very nicely for me. It needs more testing, so don't apply this yet, especially as I just noticed it has some stuff (I forgot to do a commit locally) in there with which Alex was not happy and/or had no time to look at it yet. Things to ignore: - editor.propertiesgrid - display name changes for Font and Style Comments to the patch: - I named the property a bit differently as you suggested to reduce the potential of a conflict - Would also like to be able to pass the "data" in without having to set it in the shell, currently I just created a variable and set it and then check for that in "get_report_data". Not very clean, should probably be done with a method, no? Have started implementing things on my side to be able to call the designer, looks good so far but needs more testing. Will keep working on this over the next few days and will create an updated/cleaned patch sometimes next week. Let me know if you have any issues with how I did things so far. Best regards Werner |
From: Den P. <kac...@gm...> - 2012-12-18 16:59:52
|
2012/12/18 Werner F. Bruhin <wer...@fr...>: > would a patch along these lines be acceptable Yes, I think it whould be usefull. You can also try to link Environment with Frame, not with App, to be able to create many editor Frames. But I don't know, how to organize normal access to such linking, except of passing Environment to any created object... |
From: Den P. <kac...@gm...> - 2012-12-18 13:50:51
|
Hi, > > I would like to be able to use the Editor within my wxPython > application, i.e. open a wx.Frame which contains the editor. > > I don't think this is possible the way things are structured at the > moment, am I correct or am I missing something? > > If above is correct, what about moving all the non wx methods from > EditorApplication to EditorForm? So, EditorApplication would be used in > "stand alone" mode and EditorForm would be used if one wants to use it > from within another wxPython application. > EditorApplication is used as global environment for now, because of 1) All editor elements are not completely independent one from each other according editor's logic. However, in my opinion they shouldn't be linked directly between modules, because of it makes code unreadable and hardly debuggable. EditorApplication is such bridge, that knows about any editor part and control them. 2) Such bridge must be accessible from any part of editor, so the best way to do this is to use wx mechanism for such global things - wx.App and wx.GetApp(). EditorForm isn't accessible from any part of editor. And I don't think we should pass it to all modules. I see two variants to solve your problem: 1) You can try to inherit your wx.App class from EditorApplication and override __init__ and OnInit methods, according your needs. 2) More clear way. Split EditorApplication to two classes. EditorEnvironment(object): def _init_(self, frame): self.frame = frame self.last_focus = None self.last_directory = None ..... #all methods from EditorApplication except __init__ and OnInit EditorApplication(wx.App): def __init__(self): wx.App.__init__(self, *args, **kwargs) #disable logs to prevent automatic error windows wx.Log.EnableLogging(False) def OnInit(self): self.env = EditorEnvironment(EditorForm(None)) self.SetTopWindow(self.env.frame) self.env.frame.Show() self.env.frame.Maximize(True) return True @property def editor_env(self): return self.env And then fix all calls of wx.GetApp().something to wx.GetApp().editor_env.something in editor. Then you can create EditorEnvironment in your application where you want, and then just put such property in your app @property def editor_env(self): return my_created_environment However, both solutions won't work, if you want to be able to create many forms of an editor. Anyway, EditorForm, and EditorEnvironment are different things that perform different tasks. We souldn't mix them. Den |
From: Werner F. B. <wer...@fr...> - 2012-12-18 11:38:41
|
Hi, I would like to be able to use the Editor within my wxPython application, i.e. open a wx.Frame which contains the editor. I don't think this is possible the way things are structured at the moment, am I correct or am I missing something? If above is correct, what about moving all the non wx methods from EditorApplication to EditorForm? So, EditorApplication would be used in "stand alone" mode and EditorForm would be used if one wants to use it from within another wxPython application. Werner |
From: Werner F. B. <wer...@fr...> - 2012-12-11 16:49:15
|
Hi Alex, On 10/12/2012 18:51, alexander smishlajev wrote: > Werner F. Bruhin wrote, at 10.12.2012 16:52: >> How do I see in the designer which font/style applies to field? > I don't think you can, at present. Evaluating the styles to find which > font applies is a task of report builder; template editor does not have > enough brains for that. I did not explain well what I think would be nice to see. I am not looking to see what font/style applies but what font/style is defined at a certain level without having to open the list. In other words, if I define "specialfieldstyle" on a field I like to see in the property grid instead of: (style_list) to show: (style_list - specialfieldstyle) or something along these lines if on a particular field no style is defined then it would still show: (style_list) In which case I have to go up the hierarchy to see what would apply. Werner |
From: Werner F. B. <wer...@fr...> - 2012-12-11 14:13:55
|
Hi Alex, Sorry for previous direct email, need to get used to use "reply to list":-( . On 11/12/2012 14:52, alexander smishlajev wrote: > Werner F. Bruhin wrote, at 11.12.2012 15:16: >> >>>> Just noticed that if my report is defined "A4" and I check "landscape" >>>> the preview is still showing it in "portrait" view. >>> I am sorry, I do not see how wxPrintout can control page orientation. >> >> I never used the wx print framework, so take the following with a grain >> of salt. >> >> In the wxPython demo (I use 2.9.4.0) there is an button "Page setup" and >> if I select landscape in there and then do Preview I see a difference >> between landscape and default portrait layout. > > Do you mean that wxPreviewFrame should have a button for print setup? > > I agree. Still, that does not solve the per-page size/orientation > question. That means that on certain reports wx-based preview will > appear incorrect. No, I don't think the Preview in PythonReports should have a button, it should pick up the page definition of the template and do the necessary thing to show it correctly - if nothing is defined then default e.g. to A4 portrait. Best regards Werner |
From: alexander s. <al...@go...> - 2012-12-11 10:55:13
|
On 10.12.2012 13:39, Werner F. Bruhin wrote: > > Just noticed that if my report is defined "A4" and I check "landscape" > the preview is still showing it in "portrait" view. I am sorry, I do not see how wxPrintout can control page orientation. Best wishes, alex. |
From: alexander s. <al...@go...> - 2012-12-11 10:55:10
|
On 10.12.2012 16:44, Werner F. Bruhin wrote: > > When an expression is used on a field it shows as "%EX", maybe instead > it could show the actual expression or at least part of it? Needs computation of the part that can be shown. I am not sure if the goal is worth the effort. > Following one possible way of doing this, works in my simple test cases > but might need to be expanded to cover all different usages of expression. Tried it with the sakila template. That looks worse than a constant marker. Best wishes, alex. |
From: alexander s. <al...@go...> - 2012-12-10 17:52:20
|
Werner F. Bruhin wrote, at 10.12.2012 16:52: > > How do I see in the designer which font/style applies to field? I don't think you can, at present. Evaluating the styles to find which font applies is a task of report builder; template editor does not have enough brains for that. > Currently I seem to have to look at the field, click the list and see if > there is something defined, if not go up to the section and repeat > checking the list and if not go up to the report and check the list again. > > Instead of what is shown now: > > (style_list) or (font_list) > > could it show e.g.: > > (font_list) - selected font name That would be nontrivial with conditional and inherited styles. > Currently the Edit list shows e.g. for fonts something like: > > font13 > font14 > font15 > font16 > > Could it show instead the name of the fonts? > > title > pagetitle > body > bold > > If I can come up with a patch would above be fine or would you like > something different? Font names are fine. Even better would be name followed by font specs in brackets, like this: pagetitle (14bi:Helvetica) Best wishes, alex. |
From: Werner F. B. <wer...@fr...> - 2012-12-10 14:50:50
|
Hi, How do I see in the designer which font/style applies to field? Currently I seem to have to look at the field, click the list and see if there is something defined, if not go up to the section and repeat checking the list and if not go up to the report and check the list again. Instead of what is shown now: (style_list) or (font_list) could it show e.g.: (font_list) - selected font name Currently the Edit list shows e.g. for fonts something like: font13 font14 font15 font16 Could it show instead the name of the fonts? title pagetitle body bold If I can come up with a patch would above be fine or would you like something different? Werner |
From: Werner F. B. <wer...@fr...> - 2012-12-10 14:42:59
|
Hi, When an expression is used on a field it shows as "%EX", maybe instead it could show the actual expression or at least part of it? Werner Following one possible way of doing this, works in my simple test cases but might need to be expanded to cover all different usages of expression. === modified file PythonReports/editor/elements/design.py --- PythonReports/editor/elements/design.py 2012-12-09 09:33:39 +0000 +++ PythonReports/editor/elements/design.py 2012-12-10 13:53:45 +0000 @@ -463,7 +463,7 @@ DEFAULT_FONT_SIZE = 8 DEFAULT_TEXT = "[Empty Field]" NOT_FOUND_TEXT = "[Data not found]" -EXPRESSION_TEXT = "%EX" +EXPRESSION_TEXT = "Ex: %s" class Field(ShapeBase, wxogl.TextShape): """Visual field element""" @@ -537,7 +537,7 @@ _data = self.get_value("data", self.BODY_PROPERTY) if _expr and _expr != "": - self.set_text(EXPRESSION_TEXT) + self.set_text(EXPRESSION_TEXT % _expr) elif _pre_data and _pre_data != "": self.set_text(_pre_data) elif self.get_value("data", self.EXISTANCE_PROPERTY) and _data != "": |
From: Werner F. B. <wer...@fr...> - 2012-12-10 11:38:37
|
Hi, Just noticed that if my report is defined "A4" and I check "landscape" the preview is still showing it in "portrait" view. Werner |