graphing and reporting

You could try the wxHTML stuff. I'm not sure how well it formats documents
for print, but it does a fine job of producing `screen' reports.

jw

-->-----Original Message-----
-->From: Timothy Smith [mailto:timothy@open-networks.net]
-->Sent: Wednesday, September 28, 2005 2:38 AM
-->To: wxpython-users@lists.wxwidgets.org
-->Subject: [wxPython-users] graphing and reporting
-->
-->i'm currently using a tool called reportlab to create pdf based reports
-->and graphs, but i'm looking atpossibly ditching it in favour of
-->something wx native. it'd mean i don't have to use a pdf viewer to look
-->at reports. are their any decent options in wx? if i could user sizers
-->etc to format my reports it'd make it really nice and easy to use.
-->
-->---------------------------------------------------------------------
-->To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
-->For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

yeah i need to be able to do complex graphs and grids and be able to print them out. the reason i'm using pdf is because i also know it will look right no matter what the platform.

Wyant, Jaime wrote:

···

You could try the wxHTML stuff. I'm not sure how well it formats documents
for print, but it does a fine job of producing `screen' reports.

jw

-->-----Original Message-----
-->From: Timothy Smith [mailto:timothy@open-networks.net]
-->Sent: Wednesday, September 28, 2005 2:38 AM
-->To: wxpython-users@lists.wxwidgets.org
-->Subject: [wxPython-users] graphing and reporting
-->
-->i'm currently using a tool called reportlab to create pdf based reports
-->and graphs, but i'm looking atpossibly ditching it in favour of
-->something wx native. it'd mean i don't have to use a pdf viewer to look
-->at reports. are their any decent options in wx? if i could user sizers
-->etc to format my reports it'd make it really nice and easy to use.
-->
-->---------------------------------------------------------------------
-->To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
-->For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

Sound like a postScriptDC might be what you need. You could draw
just about anything to the post script device context and then convert
it to pdf.

Matt Kubilus wrote:

Sound like a postScriptDC might be what you need. You could draw just about anything to the post script device context and then convert it to pdf.

yeah but i'd still need to use an external program to display the pdf file. i'd much rather display it in a wx native window.

Are you saying that there’s something that tracks drawing operations within a DC and outputs pdf?

···

From: Matt Kubilus [mailto:mattkubilus@gmail.com]
Sent: Friday, 30 September 2005 1:08 AM
To: wxPython-users@lists.wxwidgets.org
Subject: Re: [wxPython-users] graphing and reporting

Sound like a postScriptDC might be what you need. You could draw just about anything to the post script device context and then convert it to pdf.

Steven Reddie wrote:

Are you saying that there's something that tracks drawing operations within a DC and outputs pdf?

No, there is no such thing, which is a shame. That would be a PdfDC, which would be very valuable. However, at the C++ level someone has recently released a PDF writer library. Unfortunately, it's not wxDC compatible, but the author is talking about using it to write a PdfDC, so we may just get one! Then we'd need it wrapped for Python, or course, so it's not happening next week.

Depending on what systems you need to run your app on, it might not be too hard to generate Postscript, and then use another tool to turn that into a PDF.

Here's one option:

-Chris

Chris Barker wrote:

Steven Reddie wrote:

Are you saying that there's something that tracks drawing operations within a DC and outputs pdf?

No, there is no such thing, which is a shame. That would be a PdfDC, which would be very valuable. However, at the C++ level someone has recently released a PDF writer library. Unfortunately, it's not wxDC compatible, but the author is talking about using it to write a PdfDC, so we may just get one! Then we'd need it wrapped for Python, or course, so it's not happening next week.

Depending on what systems you need to run your app on, it might not be too hard to generate Postscript, and then use another tool to turn that into a PDF.

Here's one option:

PStill - PDF converter

-Chris

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

i currently use reportlab but it's a shame i have to use a 3rd party tool to then open the pdf. it'd be much much faster to display it in a wx native view and then write/print

Timothy Smith wrote:

i currently use reportlab but it's a shame i have to use a 3rd party tool to then open the pdf. it'd be much much faster to display it in a wx native view and then write/print

Absolutely. If you're up to it, look into wrapping the new PDFwriter code for Python!

-Chris

Chris Barker wrote:

Timothy Smith wrote:

i currently use reportlab but it's a shame i have to use a 3rd party tool to then open the pdf. it'd be much much faster to display it in a wx native view and then write/print

Absolutely. If you're up to it, look into wrapping the new PDFwriter code for Python!

-Chris

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

just point me to it. it would be a great asset to wx

Timothy Smith wrote:

Chris Barker wrote:

If you're up to it, look into wrapping the new PDFwriter code for Python!

just point me to it. it would be a great asset to wx

http://wxcode.sourceforge.net/components/wxpdfdoc/

There was discussion about it on wx-users in the beginning of Sept.

The author has talked about using it to make a wxPdfDC, which would be wonderful. However, in the meantime, if you wrapped wxpdfdoc for Python, using it to write a wxPdfDC in Python would be fairly straightforward.

-Chris

Simply layout your graph in whatever format looks good in a scrolled
window. Then capture the device context of that frame, put it
into a printerDC (i’m assuming you can do this with a postscriptDC as
well). Then convert the postscript file into a pdf. You can
put just about anything into a device context. I could probably
dig up a sample when I get to my desk on monday.

–Matt

Matt Kubilus wrote:

Simply layout your graph in whatever format looks good in a scrolled window. Then capture the device context of that frame, put it into a printerDC (i'm assuming you can do this with a postscriptDC as well). Then convert the postscript file into a pdf. You can put just about anything into a device context. I could probably dig up a sample when I get to my desk on monday.

--Matt

that would be great

With something like the following you can get a bitmap of a scrolled
window and put this into a device context. Your not limited to
drawing the bitmap on the device context, but could draw other things
as well. Take a look at the wxpython demo.

#!/usr/bin/env python

printScrolledWindow.py

“”"
printScrolledWindow.py

    Prints a scrolled window.

    Inputs: ScrolledWindow
       
    Ouputs: Printout

“”"

from wxPython.wx import *
from math import *

def getBitmapFromScrolledPanel(panel):
xScroll,yScroll = panel.GetScrollPixelsPerUnit()
panel.SetScrollRate(1,1)

xSource = ySource = xDest = yDest = 0.0

visibleWidth, visibleHeight = panel.GetSizeTuple()
virtualWidth, virtualHeight = panel.GetVirtualSize()
bm = wxEmptyBitmap(virtualWidth, virtualHeight)
tempDC = wxMemoryDC()
tempDC.SelectObject(bm)

visibleWidth = visibleWidth - 17
visibleHeight = visibleHeight - 17

xUnits = visibleWidth
yUnits = visibleHeight

#print "XUNITS: " + str(xUnits)
#print "YUNITS: " + str(yUnits)

xSegments = int(ceil(float(virtualWidth)/float(xUnits)))
ySegments = int(ceil(float(virtualHeight)/float(yUnits)))

#print "XSEGMENTS: " + str(xSegments)
#print "YSEGMENTS: " + str(ySegments)

for x in range(xSegments):
    if ((x * xUnits) + xUnits) < virtualWidth:
        xDest = xUnits * x
    else:
        xDest = xDest + (virtualWidth - xUnits)
    panel.Scroll(xDest, -1)
    #print "XDEST: " + str(xDest)
    for y in range(ySegments):
        if ((y * yUnits) + yUnits) < virtualHeight:
            yDest = yUnits * y
        else:

yDest = (yUnits * y) - ((yUnits * (y + 1)) - virtualHeight)
panel.Scroll(-1, yDest)
#print "YDEST: " + str(yDest)
panel.Update()
panelDC = wxClientDC(panel)

tempDC.Blit(xDest, yDest, visibleWidth, visibleHeight, panelDC,
xSource, ySource)

panel.SetScrollRate(xScroll, yScroll)

#print bm.GetWidth()
#print bm.GetHeight()
#print panel.GetVirtualSize()

return bm

class scrolledPrintout(wxPrintout):
def init(self, panel, title):
self.bitmap = getBitmapFromScrolledPanel(panel)
wxPrintout.init(self, title)

def OnPrintPage(self, pgno):
    dc = self.GetDC()
    dc.StartDoc("Start")
    dc.StartPage()

    printerWidth, printerHeight = dc.GetSizeTuple()

    bmWidth = self.bitmap.GetWidth()
    bmHeight = self.bitmap.GetHeight()

    scaleWidth = float(printerWidth/bmWidth)
    scaleHeight = float(printerHeight/bmHeight)
    dc.SetUserScale(min(scaleWidth, scaleHeight), min(scaleWidth, scaleHeight))
    dc.DrawBitmap(self.bitmap, 0,0)
    #bm.SaveFile("aBitmap.bmp", wxBITMAP_TYPE_BMP )

    dc.EndPage()
    dc.EndDoc()

def OnPrintPage(self, pgno):
    dc = self.GetDC()
···
    #-------------------------------------------
    # One possible method of setting scaling factors...

    maxX = self.bitmap.GetWidth()
    maxY = self.bitmap.GetHeight()

    # Let's have at least 50 device units margin
    marginX = 15
    marginY = 15

    # Add the margin to the graphic size
    maxX = maxX + (2 * marginX)
    maxY = maxY + (2 * marginY)

    # Get the size of the DC in pixels
    (w, h) = dc.GetSizeTuple()

    # Calculate a suitable scaling factor
    scaleX = float(w) / maxX
    scaleY = float(h) / maxY

    # Use x or y scaling factor, whichever fits on the DC
    actualScale = min(scaleX, scaleY)

    # Calculate the position on the DC for centering the graphic
    posX = (w - (self.bitmap.GetWidth() * actualScale)) / 2.0
    posY = (h - (self.bitmap.GetHeight() * actualScale)) / 2.0

    # Set the scale and origin
    dc.SetUserScale(actualScale, actualScale)
    dc.SetDeviceOrigin(int(posX), int(posY))

    #-------------------------------------------

    dc.DrawBitmap(self.bitmap, 0,0)
    dc.DrawText("Page: %d" % pgno, marginX/2, maxY-marginY)

    return True

def GetPageInfo(self):
    return (1, 1, 1, 1)

On 10/2/05, Timothy Smith timothy@open-networks.net wrote:

Matt Kubilus wrote:

Simply layout your graph in whatever format looks good in a scrolled
window. Then capture the device context of that frame, put it into a
printerDC (i’m assuming you can do this with a postscriptDC as well).

Then convert the postscript file into a pdf. You can put just about
anything into a device context. I could probably dig up a sample when
I get to my desk on monday.

–Matt

that would be great


To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org

For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org


Don’t be a pioneeer. A pioneer is the guy with the arrow through his chest. – John J. Rakos