Printing (was Re: wxOscilloscope was moving pyplot)

Peter Wurmsdobler <peter.wurmsdobler@eurothermdrives.com> writes:

class PlotCanvas(wx.wxWindow):
    """Subclass of a wxWindow to allow simple general plotting
    of data with zoom, labels, and automatic axis scaling."""

(...)

class plot_printout(wx.wxPrintout):
    """Controls how the plot is made in printing and previewing"""

(...)

These classes interested me a lot 'cause I'm still trying to print a
grid in a program of mine. How can I pass an arbitrary object to
<yourclass>.PrintPreview() or <yourclass>.Printout()?

I tried something like:

<yourclass>.PrintPreview(grid_from_a_notebook_page)

after changing PrintPreview() to accept an additional parameter to
override what I'm going to print:

···

----------------------------------------------------------------------
    def PrintPreview(self, inst):
        """
        Print-preview current plot.
        """
        printout = plot_printout(self)
        printout2 = plot_printout(self)
        self.preview = wx.wxPrintPreview(printout, printout2, self.print_data)
        if not self.preview.Ok():
            wx.wxMessageDialog(self, "Print Preview failed.\n" \
                               "Check that default printer is configured\n", \
                               "Print error", wx.wxOK|wx.wxCENTRE).ShowModal()
        self.preview.SetZoom(30)
        #search up tree to find frame instance
        frameInst = inst
        while not isinstance(frameInst, wx.wxFrame):
            print frameInst
            frameInst = frameInst.GetParent()
        frame = wx.wxPreviewFrame(self.preview, frameInst, "Preview")
        frame.Initialize()
        frame.SetPosition(self.GetPosition())
        frame.SetSize((500,400))
        frame.Centre(wx.wxBOTH)
        frame.Show(True)
----------------------------------------------------------------------

The result of the above 'print' statement is:

----------------------------------------------------------------------
<wxPython.grid.wxGrid instance; proxy of C++ wxGrid instance at _86edc38_wxGrid_p>
<wxPython.windows.wxPanel instance; proxy of C++ wxPanel instance at _86bb2b8_wxPanel_p>
<wxPython.windows2.wxNotebook instance; proxy of C++ wxNotebook instance at _868b070_wxNotebook_p>
----------------------------------------------------------------------

I am almost sure I don't want a wx.wxFrame, but I couldn't find out
how to pass it a wxGrid to be compared with the instance I'm trying to
print.

I am not being able to figure out this printing interface from the
docs or the demo... I'll try it more and I'll be fiddling with your
code --- which helped understanding some things --- but I'd greatly
appreciate any hints on where to find some docs or how to do that.

TIA,
--
Godoy. <godoy@metalab.unc.edu>

Jorge,

These classes interested me a lot 'cause I'm still trying to print a
grid in a program of mine. How can I pass an arbitrary object to
<yourclass>.PrintPreview() or <yourclass>.Printout()?

Unfortunatley, I cannot answer this. The PyPLot author Gordon Williams
probably can.
peter

Jorge Godoy wrote:

> class PlotCanvas(wx.wxWindow):
> """Subclass of a wxWindow to allow simple general plotting
> of data with zoom, labels, and automatic axis scaling."""

(...)

> class plot_printout(wx.wxPrintout):
> """Controls how the plot is made in printing and previewing"""

(...)

These classes interested me a lot 'cause I'm still trying to print a
grid in a program of mine. How can I pass an arbitrary object to
<yourclass>.PrintPreview() or <yourclass>.Printout()?

The printing classes in wxPyPlot are pretty specialized for that
particular purpose. YOu can probaly learn form them, but you're not
going to be able to just pass your object in to them.

I'd check out the demo and docs for more info. Be sure to look at the
TablePrint Demo under More Windows/controls in the demo.

-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@noaa.gov