reporting framework for wx (was: ideas for Andrea)

Hello all,

I wish to start a discussion about the necessity for a reporting framework for wxPython.

The last threads displayed, that some of you are looking for such a functionality.
For my present project I need a reporting framework. So I'm coding some basics by hand.

Some thoughts:

···

----------------------
HTMLEasyPrint: This is easy, but for creating business reports like orders, invoices, ... HTML lacks of tools for positioning elements on the canvas.

ReportLab: The mighty tool for creating top quality PDF. The problem with RL is, that the user need another program to print out the files.

PrintTable: Is ok for printing only tables.
----------------------
At this time I use some functionalty to scale and convert device units into "paper" units. That's working quite well.
The report is an easy structured XML file with all fields in it:
...
<to>
  <name y="23" x="25" type="text">Andreas Kaiser</name>
  <street y="23" x="25" type="text">The Street 23</street>
</to>
...

X and Y are in millimeters.
Other types are tables. This not working well at this time.

I parse the XML file and call some functions for converting the units and drawing the elements on the canvas.

PySketch was mentioned for laying out a report. This thought is looking good.

I hope that we can start a discussion and create such a reporting framework for wxPython.

Andreas

PySketch was mentioned for laying out a report. This thought is
looking good.

Yes. it's possible to use the code as a starting point to build a
report designer.

I hope that we can start a discussion and create such a reporting
framework for wxPython.

Me too, since I have some ideias. I already have a prototype/draft
implemented for some of them. I don't know if it's the best approach so
I attach the code for someone to comment. Since this is a draft, the
code is a little bit messy/ugly. There are almost any comments and some
of them are in Portuguese. Just run the demo.py and, unless you are
brave :), just look to the demo.py source.

If someone wants/need to understand my approach, I can explain it
better.

Ricardo

report.zip (45 KB)

···

On Sun, 2005-11-20 at 14:37 +0100, Andreas Kaiser wrote:

Forgot to mention that those ideias were taken from Informix4GL.

Ricardo

···

On Mon, 2005-11-21 at 05:41 +0000, Ricardo Pedroso wrote:

On Sun, 2005-11-20 at 14:37 +0100, Andreas Kaiser wrote:

> PySketch was mentioned for laying out a report. This thought is
> looking good.

Yes. it's possible to use the code as a starting point to build a
report designer.

> I hope that we can start a discussion and create such a reporting
> framework for wxPython.

Me too, since I have some ideias.

Hi Ricardo,

Ricardo Pedroso schrieb:

PySketch was mentioned for laying out a report. This thought is looking good.

Yes. it's possible to use the code as a starting point to build a
report designer.

I think, this should be the second step.

I hope that we can start a discussion and create such a reporting framework for wxPython.

Me too, since I have some ideias. I already have a prototype/draft
implemented for some of them. I don't know if it's the best approach so
I attach the code for someone to comment. Since this is a draft, the
code is a little bit messy/ugly. There are almost any comments and some
of them are in Portuguese. Just run the demo.py and, unless you are
brave :), just look to the demo.py source.

If someone wants/need to understand my approach, I can explain it
better.

I've tried your demo and it looks good! Now I integrate your "reportengine" in my app. Then you get response from me, how this works.

Andreas

···

On Sun, 2005-11-20 at 14:37 +0100, Andreas Kaiser wrote:

Me too, since I have some ideias. I already have a prototype/draft
implemented for some of them. I don't know if it's the best approach so
I attach the code for someone to comment. Since this is a draft, the
code is a little bit messy/ugly. There are almost any comments and some
of them are in Portuguese. Just run the demo.py and, unless you are
brave :), just look to the demo.py source.

If someone wants/need to understand my approach, I can explain it
better.

Ricardo

Demo is lookingf very nice!

I was tweaking printout.py code for some time, and when I've done,
then you post your code. :slight_smile:
Actualy I think that wxPython needs report tool too, because almost
all aplications need printing, especially db applications.

Hi Ricardo,

Ricardo Pedroso schrieb:
>
>> PySketch was mentioned for laying out a report. This thought is
>> looking good.
>
> Yes. it's possible to use the code as a starting point to build a
> report designer.
I think, this should be the second step.

Or the last one. Personally I don't care about graphical designers. But
I know that they play a big role to a user when he needs to make a
decision to use a tool.

>> I hope that we can start a discussion and create such a reporting
>> framework for wxPython.
>
> Me too, since I have some ideias. I already have a prototype/draft
> implemented for some of them. I don't know if it's the best approach so
> I attach the code for someone to comment. Since this is a draft, the
> code is a little bit messy/ugly. There are almost any comments and some
> of them are in Portuguese. Just run the demo.py and, unless you are
> brave :), just look to the demo.py source.
>
> If someone wants/need to understand my approach, I can explain it
> better.
I've tried your demo and it looks good! Now I integrate your
"reportengine" in my app. Then you get response from me, how this works.

Great. If you can make it print in a real printer it would be nice,
because at the moment I don't have one.

Ricardo

···

On Mon, 2005-11-21 at 13:22 +0100, Andreas Kaiser wrote:

> On Sun, 2005-11-20 at 14:37 +0100, Andreas Kaiser wrote:

> Me too, since I have some ideias. I already have a prototype/draft
> implemented for some of them. I don't know if it's the best approach so
> I attach the code for someone to comment. Since this is a draft, the
> code is a little bit messy/ugly. There are almost any comments and some
> of them are in Portuguese. Just run the demo.py and, unless you are
> brave :), just look to the demo.py source.
>
> If someone wants/need to understand my approach, I can explain it
> better.
>
> Ricardo

Demo is lookingf very nice!

I was tweaking printout.py code for some time, and when I've done,
then you post your code. :slight_smile:

If you want to share it will be great. It's good to see other points of
view about the same subject.

Actualy I think that wxPython needs report tool too, because almost
all aplications need printing, especially db applications.

Yes, db applications are my main target. if you look into the demo.py
you will see that the data is in a list, and that list can come from a
query against a database.

Ricardo

···

On Mon, 2005-11-21 at 15:56 +0200, viestards wrote:

I thought I'd add to the discussion that we've been working on a reporting framework for Dabo. It is split into a Report Writer and a Report Designer (the Report Writer is part of Dabo; the Report Designer is part of daboide). The Report Writer takes a rfxml file, which is a definition of report bands and objects in XML format, and a data cursor, which is a tuple of dicts representing records and fields, and outputs a PDF which you can display/print/email/whatever.

The Report Writer is basically a wrapper around ReportLab, and includes such concepts as report variables, report grouping, starting groups on new pages, report group header/footer bands, absolute or relative positioning, stretching the band height to accomodate overflow, and dynamic evaluation of almost everything (change the font color based on the value of a data field, for example).

The Report Designer is what you use to create/modify your rfxml files. It is graphical, point-and-click, and includes the same property sheet used in the Dabo GUI Designer. There are 3 main pages: one, the design surface; two, a page letting you directly edit the xml (and any changes you make reflect immediately on the design surface, and vice-versa); three, a report preview, letting you see immediately the effects of your changes in the form of the final PDF.

The Report Designer works on the simplest reports, but still needs lots of work. The Report Writer is still young as well, but allows for some pretty complex reports if you are willing to hand-code them yourself by starting with boilerplate xml and going from there. It is still quite buggy but I'm using it for my own production use.

At the risk of overstaying my welcome here (while Dabo uses wxPython for GUI, the Dabo Report Writer doesn't rely on wxPython at all), I thought I'd post an example rfxml file in the hope that it adds to the discussion. This is an rfxml that is in production use (it prints my customer invoices).

http://paulmcnett.com/dabo-sample-report_invoice.rfxml

If the Dabo Report Writer could be seen as a good start, it wouldn't be too difficult to use it separately from Dabo itself.

···

--
Paul McNett
http://paulmcnett.com
http://dabodev.com

Andreas Kaiser wrote:

Hello all,

I wish to start a discussion about the necessity for a reporting framework for wxPython.

PySketch was mentioned for laying out a report. This thought is
looking good.

Yes I was, and here it's my contribution to the creation of the report
framework.
Ok, now this is not an application for create the report, but it's only
the skeleton of a program for make simple point-and-click report files.

If someone want / has some ideas for create something like the already
mentioned reportman, I'm here with some but (not a lot) free time.

For example, can be a good solution the reportman method of creation of
some "bands" where after the preview engine put the data passed?

Other idea that now jump into my mind is to modify my PySketch_2 for
make a report designer for the engine posted by Ricardo.

What do you think?

I hope that we can start a discussion and create such a reporting framework for wxPython.

I hope too

Andreas

Michele

PySketch_2.zip (78.2 KB)

Hi,

Michele Petrazzo schrieb:

Yes I was, and here it's my contribution to the creation of the report
framework.
Ok, now this is not an application for create the report, but it's only
the skeleton of a program for make simple point-and-click report files.

Yeah! Naming objects is done! Looks good. That was my first thought as I see the pysketch (orig) code: The objects must be named!

If someone want / has some ideas for create something like the already
mentioned reportman, I'm here with some but (not a lot) free time.

For example, can be a good solution the reportman method of creation of
some "bands" where after the preview engine put the data passed?

Other idea that now jump into my mind is to modify my PySketch_2 for
make a report designer for the engine posted by Ricardo.

What do you think?

The way looks good. For pysketch as designer, I prefer another file format then cPickle. All objects are in an dict or list. So we can write and read them as XML (eGenix?)

I hope that we can start a discussion and create such a reporting framework for wxPython.

I hope too

Then let's go! I will sort the information about this thread and put it on the list.

Andreas

Andreas Kaiser wrote:

Other idea that now jump into my mind is to modify my PySketch_2
for make a report designer for the engine posted by Ricardo.

What do you think?

The way looks good. For pysketch as designer, I prefer another file format then cPickle. All objects are in an dict or list. So we can
write and read them as XML (eGenix?)

I also prefer other formats than cPickle. but PySketch became with that
save method, so I have hold it. Can be a good solution to use XML, like
you say, but why with eGenix and not use the standard xml library? I
think that, like other users say, the better solution is to use all the
internal python / wx libraries.

I hope that we can start a discussion and create such a reporting
framework for wxPython.

I hope too

Then let's go! I will sort the information about this thread and put
it on the list.

I'm waiting for it. :slight_smile:

Andreas

Michele

Paul McNett wrote:

letting you see immediately the effects of your changes in the form of the final PDF.

How are you displaying that PDF?

while Dabo uses wxPython for GUI, the Dabo Report Writer doesn't rely on wxPython at all.

This is an issue with what the OP was looking for. Sometimes you just want the user to click "print" and have it sent to the printer. I don't know that there is a robust cross-platform way to just send a PDF to the printer transparently. Also, print preview is an issue, which is why I asked the question above.

I see the solution as one that uses a wx.DC to do the rendering, then you get print preview, printing, PS, etc. Also, with any luck there will be a PdfDC some day as well.

-Chris

···

--
Christopher Barker, Ph.D.
Oceanographer

NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris Barker wrote:

Paul McNett wrote:

letting you see immediately the effects of your changes in the form of the final PDF.

How are you displaying that PDF?

Well, eventually, I hope there will be a wxPdfWindow control. For now, we call os.startfile() on Windows and os.openfile() on Mac (why oh why are those named differently I have no idea) to launch the default PDF viewer. On Linux, we punt with any of gpdf, xpdf, evince, acroread. IOW, the preview isn't displayed within the wx app. But I'm hopeful someone will write a cross-platform pdf viewer soon!

while Dabo uses wxPython for GUI, the Dabo Report Writer doesn't rely on wxPython at all.

This is an issue with what the OP was looking for. Sometimes you just want the user to click "print" and have it sent to the printer.

Well, with a combination of knowing what printer you want to send to, and the PDF, you can do that, no?

I don't know that there is a robust cross-platform way to just send a PDF to the printer transparently. Also, print preview is an issue, which is why I asked the question above.

Right, for now we are just using whatever external viewer the user wants to use.

I see the solution as one that uses a wx.DC to do the rendering, then you get print preview, printing, PS, etc. Also, with any luck there will be a PdfDC some day as well.

This would be a great thing. I originally looked at wxPostscriptDC, but abandoned that because I was running into walls (can't remember what the walls were, though).

···

--
Paul McNett
http://paulmcnett.com
http://dabodev.com

Chris Barker wrote:
> Paul McNett wrote:
>
>> letting you see immediately the effects of your changes in
the form
>> of
>> the final PDF.
>
> How are you displaying that PDF?

Well, eventually, I hope there will be a wxPdfWindow control.
For now, we call
os.startfile() on Windows and os.openfile() on Mac (why oh
why are those named
differently I have no idea) to launch the default PDF viewer.
On Linux, we punt
with any of gpdf, xpdf, evince, acroread. IOW, the preview
isn't displayed
within the wx app. But I'm hopeful someone will write a
cross-platform pdf
viewer soon!

>> while Dabo uses wxPython for GUI, the Dabo Report Writer
doesn't rely
>> on wxPython at all.
>
> This is an issue with what the OP was looking for.
Sometimes you just
> want the user to click "print" and have it sent to the printer.

Well, with a combination of knowing what printer you want to
send to, and the
PDF, you can do that, no?

> I don't
> know that there is a robust cross-platform way to just send
a PDF to the
> printer transparently. Also, print preview is an issue,
which is why I
> asked the question above.

Right, for now we are just using whatever external viewer the
user wants to use.

> I see the solution as one that uses a wx.DC to do the
rendering, then
> you get print preview, printing, PS, etc. Also, with any
luck there will
> be a PdfDC some day as well.

This would be a great thing. I originally looked at
wxPostscriptDC, but
abandoned that because I was running into walls (can't
remember what the walls
were, though).

One quick comment on this issue....

At the moment, Transana uses a read-only, print-preview approach to reports,
using the wx Print Framework. I've had a significant number of users
complain about this approach because they want to be able to capture
portions of the report text for inclusion in articles, reports they're
writing, etc.

In my opinion, any solution you consider for a reporting framework should
allow printing, saving of reports (perhaps in a couple of formats), and the
cut-and-paste capture of report text for re-purposing.

Just my 2 cents worth.

David
http://www.transana.org

David Woods wrote:

One quick comment on this issue....

At the moment, Transana uses a read-only, print-preview approach to reports,
using the wx Print Framework. I've had a significant number of users
complain about this approach because they want to be able to capture
portions of the report text for inclusion in articles, reports they're
writing, etc.

In my opinion, any solution you consider for a reporting framework should
allow printing, saving of reports (perhaps in a couple of formats), and the
cut-and-paste capture of report text for re-purposing.

I totally agree. A PDF would give you all of this, no? I'm thinking from the frame of mind that from a PDF, you can:

+ view
+ print
+ save
+ do all this cross-platform, and be relatively sure the report displays the same on all platforms
+ copy text blocks from the report
+ convert the report to other formats (pdf2ascii, pdf2png, etc.)
+ use adobe acrobat or other pdf tools to modify the output or put it in a bigger document, etc.

It just seems to me that the PDF format covers almost all needs, at least for business-type reporting for print and display.

···

--
Paul McNett
http://paulmcnett.com
http://dabodev.com

David Woods wrote:
> One quick comment on this issue....
>
> At the moment, Transana uses a read-only, print-preview approach to
> reports, using the wx Print Framework. I've had a
significant number
> of users complain about this approach because they want to
be able to
> capture portions of the report text for inclusion in
articles, reports
> they're writing, etc.
>
> In my opinion, any solution you consider for a reporting framework
> should allow printing, saving of reports (perhaps in a couple of
> formats), and the cut-and-paste capture of report text for
> re-purposing.

I totally agree. A PDF would give you all of this, no? I'm
thinking from the
frame of mind that from a PDF, you can:

+ view
+ print
+ save
+ do all this cross-platform, and be relatively sure the report displays

the same on all platforms

+ copy text blocks from the report
+ convert the report to other formats (pdf2ascii, pdf2png, etc.) use
+ adobe acrobat or other pdf tools to modify the output or put it in a

bigger document, etc.

It just seems to me that the PDF format covers almost all
needs, at least for
business-type reporting for print and display.

Yes, though I've always found copying a block of text from a PDF a little
awkward.

But will the wx.PdfDC support all of this? I certainly hope so.

I'm eager to see what comes of this discussion, because I know I need to
rewrite my report framework down the road, in my copious free time.

David

Hi,

Andreas Kaiser wrote:

I will sort the information about this thread and put it on the list.

Should we use the wxPython wiki for discuss and collect the infos about reporting framework?

Andreas

Hi Michele,

Michele Petrazzo schrieb:

Other idea that now jump into my mind is to modify my PySketch_2 for
make a report designer for the engine posted by Ricardo.

What do you think?

I've played with your pysketch2. Following point are remarkable:

1. Draw an easy sketch, esp. textObjects.
2. Name the textObjects.
3. Save the file.

4. At line 1989 (in loadContents):

         for layer, type, data in objData:
             print data
             if data[23] == 'Text0': #This is the name of my textObject
                 data[16] = u'Andreas' # change the content
             obj = DrawingObject(type, layer=layer)
             obj.setData(data)
             self.Contents[layer].append(obj)
             self.__objCounter[type] +=1

5. Voila, it works!

With pysketch we can preview, setup, print only with wxPython. So I think, there is a way to separate pysketch in a designer part (already done ;-))) and a control for embedding in the wxPython app. The control has only the load, preview, setup, print functions.

Questions:
What about the core function for reporting DB-tables? How can we made this?
What about page breaks?

For the moment, I will play around with the pysketch solution.

Andreas

Hi Paul,

This sounds very interesting.

One question, does it handle I18n issues? I.e. can one report
definition handle multiple languages for all the text strings
(preferably using gettext) and are date formats adjusted to the user
settings (mm/dd/yyyy or dd/mm/yyyy etc etc)?

See you
Werner

Paul McNett wrote:

···

I thought I'd add to the discussion that we've been working on a reporting framework for Dabo. It is split into a Report Writer and a Report Designer (the Report Writer is part of Dabo; the Report Designer is part of daboide). The Report Writer takes a rfxml file, which is a definition of report bands and objects in XML format, and a data cursor, which is a tuple of dicts representing records and fields, and outputs a PDF which you can display/print/email/whatever.

The Report Writer is basically a wrapper around ReportLab, and includes such concepts as report variables, report grouping, starting groups on new pages, report group header/footer bands, absolute or relative positioning, stretching the band height to accomodate overflow, and dynamic evaluation of almost everything (change the font color based on the value of a data field, for example).

The Report Designer is what you use to create/modify your rfxml files. It is graphical, point-and-click, and includes the same property sheet used in the Dabo GUI Designer. There are 3 main pages: one, the design surface; two, a page letting you directly edit the xml (and any changes you make reflect immediately on the design surface, and vice-versa); three, a report preview, letting you see immediately the effects of your changes in the form of the final PDF.

The Report Designer works on the simplest reports, but still needs lots of work. The Report Writer is still young as well, but allows for some pretty complex reports if you are willing to hand-code them yourself by starting with boilerplate xml and going from there. It is still quite buggy but I'm using it for my own production use.

At the risk of overstaying my welcome here (while Dabo uses wxPython for GUI, the Dabo Report Writer doesn't rely on wxPython at all), I thought I'd post an example rfxml file in the hope that it adds to the discussion. This is an rfxml that is in production use (it prints my customer invoices).

http://paulmcnett.com/dabo-sample-report_invoice.rfxml

If the Dabo Report Writer could be seen as a good start, it wouldn't be too difficult to use it separately from Dabo itself.

http://paulmcnett.com/dabo-sample-report_invoice.rfxml

I think it would be nice to see PDF output of this report.
  And most complex case which this Writer could handle, i.e. subtotals,
totals, images, page margins, coloring lines (for example negative ones)
etc...
Is it possible?
Can it handle non latin letters (other languages) as well?
Can it work on Windows?
I'm willing to test it if you show me where i can get it.
I'm afraid my proxy have blocked CVS access, so can't get to CVS port.

If the Dabo Report Writer could be seen as a good start, it wouldn't be too
difficult to use it separately from Dabo itself.

That's good.
I have evaluated last Dabo build (from site, not from CVS) but didn't find any reporting tools in it.

···

--
Igor.
                         mailto:igor@tyumbit.ru