phoenix_title wx.PrintPreview

Objects of this class manage the print preview process.

The object is passed a wx.Printout object, and the wx.PrintPreview object itself is passed to a wx.PreviewFrame object. Previewing is started by initializing and showing the preview frame. Unlike wx.Printer.Print , flow of control returns to the application immediately after the frame is shown.

Note

The preview shown is only exact on Windows. On other platforms, the wx.DC used for preview is different from what is used for printing and the results may be significantly different, depending on how is the output created. In particular, printing code relying on wx.DC.GetTextExtent heavily (for example, wx.html.HtmlEasyPrinting and other HTML classes do) is affected. It is recommended to use native preview functionality on platforms that offer it (macOS, GTK+).

See also

Printing Framework Overview, wx.PrinterDC, wx.PrintDialog, wx.Printout, wx.Printer, wx.PreviewCanvas, wx.PreviewControlBar, wx.PreviewFrame


class_hierarchy Class Hierarchy

Inheritance diagram for class PrintPreview:

method_summary Methods Summary

__init__

Constructor.

GetCanvas

Gets the preview window used for displaying the print preview image.

GetCurrentPage

Gets the page currently being previewed.

GetFrame

Gets the frame used for displaying the print preview canvas and control bar.

GetMaxPage

Returns the maximum page number.

GetMinPage

Returns the minimum page number.

GetPrintout

Gets the preview printout object associated with the wx.PrintPreview object.

GetPrintoutForPrinting

Gets the printout object to be used for printing from within the preview interface, or None if none exists.

GetZoom

Gets the current percentage zoom level of the preview canvas.

IsOk

Returns True if the wx.PrintPreview is valid, False otherwise.

PaintPage

This refreshes the preview window with the preview image.

Print

Invokes the print process using the second wx.Printout object supplied in the wx.PrintPreview constructor.

RenderPage

Renders a page into a wx.MemoryDC.

SetCanvas

Sets the window to be used for displaying the print preview image.

SetCurrentPage

Sets the current page to be previewed.

SetFrame

Sets the frame to be used for displaying the print preview canvas and control bar.

SetPrintout

Associates a printout object with the wx.PrintPreview object.

SetZoom

Sets the percentage preview zoom, and refreshes the preview canvas accordingly.

__bool__

__nonzero__


property_summary Properties Summary

Canvas

See GetCanvas and SetCanvas

CurrentPage

See GetCurrentPage and SetCurrentPage

Frame

See GetFrame and SetFrame

MaxPage

See GetMaxPage

MinPage

See GetMinPage

Printout

See GetPrintout and SetPrintout

PrintoutForPrinting

See GetPrintoutForPrinting

Zoom

See GetZoom and SetZoom


api Class API

class wx.PrintPreview(Object)

Possible constructors:

PrintPreview(printout, printoutForPrinting=None, data=None)

PrintPreview(printout, printoutForPrinting, data)

Objects of this class manage the print preview process.


Methods

__init__(self, *args, **kw)

overload Overloaded Implementations:



__init__ (self, printout, printoutForPrinting=None, data=None)

Constructor.

Pass a printout object, an optional printout object to be used for actual printing, and the address of an optional block of printer data, which will be copied to the print preview object’s print data.

If printoutForPrinting is not None, a “Print…” button will be placed on the preview frame so that the user can print directly from the preview interface.

Use IsOk to check whether the wx.PrintPreview object was created correctly.

Parameters:

Note

Do not explicitly delete the printout objects once this constructor has been called, since they will be deleted in the wx.PrintPreview destructor. The same does not apply to the data argument.



__init__ (self, printout, printoutForPrinting, data)

Parameters:





GetCanvas(self)

Gets the preview window used for displaying the print preview image.

Return type:

wx.PreviewCanvas



GetCurrentPage(self)

Gets the page currently being previewed.

Return type:

int



GetFrame(self)

Gets the frame used for displaying the print preview canvas and control bar.

Return type:

wx.Frame



GetMaxPage(self)

Returns the maximum page number.

Return type:

int



GetMinPage(self)

Returns the minimum page number.

Return type:

int



GetPrintout(self)

Gets the preview printout object associated with the wx.PrintPreview object.

Return type:

wx.Printout



GetPrintoutForPrinting(self)

Gets the printout object to be used for printing from within the preview interface, or None if none exists.

Return type:

wx.Printout



GetZoom(self)

Gets the current percentage zoom level of the preview canvas.

Return type:

int

See also

SetZoom



IsOk(self)

Returns True if the wx.PrintPreview is valid, False otherwise.

It could return False if there was a problem initializing the printer device context (current printer not set, for example).

Return type:

bool



PaintPage(self, canvas, dc)

This refreshes the preview window with the preview image.

It must be called from the preview window’s OnPaint member.

The implementation simply blits the preview bitmap onto the canvas, creating a new preview bitmap if none exists.

Parameters:
Return type:

bool



Print(self, prompt)

Invokes the print process using the second wx.Printout object supplied in the wx.PrintPreview constructor.

Will normally be called by the Print… panel item on the preview frame’s control bar.

Returns False in case of error – call wx.Printer.GetLastError to get detailed information about the kind of the error.

Parameters:

prompt (bool) –

Return type:

bool



RenderPage(self, pageNum)

Renders a page into a wx.MemoryDC.

Used internally by wx.PrintPreview.

Parameters:

pageNum (int) –

Return type:

bool



SetCanvas(self, window)

Sets the window to be used for displaying the print preview image.

Parameters:

window (wx.PreviewCanvas) –



SetCurrentPage(self, pageNum)

Sets the current page to be previewed.

Parameters:

pageNum (int) –

Return type:

bool



SetFrame(self, frame)

Sets the frame to be used for displaying the print preview canvas and control bar.

Parameters:

frame (wx.Frame) –



SetPrintout(self, printout)

Associates a printout object with the wx.PrintPreview object.

Parameters:

printout (wx.Printout) –



SetZoom(self, percent)

Sets the percentage preview zoom, and refreshes the preview canvas accordingly.

Parameters:

percent (int) –

See also

GetZoom



__bool__(self)
Return type:

int



__nonzero__(self)
Return type:

int


Properties

Canvas

See GetCanvas and SetCanvas



CurrentPage

See GetCurrentPage and SetCurrentPage



Frame

See GetFrame and SetFrame



MaxPage

See GetMaxPage



MinPage

See GetMinPage



Printout

See GetPrintout and SetPrintout



PrintoutForPrinting

See GetPrintoutForPrinting



Zoom

See GetZoom and SetZoom