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
Constructor. |
|
Gets the preview window used for displaying the print preview image. |
|
Gets the page currently being previewed. |
|
Gets the frame used for displaying the print preview canvas and control bar. |
|
Returns the maximum page number. |
|
Returns the minimum page number. |
|
Gets the preview printout object associated with the wx.PrintPreview object. |
|
Gets the printout object to be used for printing from within the preview interface, or |
|
Gets the current percentage zoom level of the preview canvas. |
|
Returns |
|
This refreshes the preview window with the preview image. |
|
Invokes the print process using the second wx.Printout object supplied in the wx.PrintPreview constructor. |
|
Renders a page into a wx.MemoryDC. |
|
Sets the window to be used for displaying the print preview image. |
|
Sets the current page to be previewed. |
|
Sets the frame to be used for displaying the print preview canvas and control bar. |
|
Associates a printout object with the wx.PrintPreview object. |
|
Sets the percentage preview zoom, and refreshes the preview canvas accordingly. |
|
See |
|
See |
|
See |
|
See |
|
wx.
PrintPreview
(Object)¶Possible constructors:
PrintPreview(printout, printoutForPrinting=None, data=None)
PrintPreview(printout, printoutForPrinting, data)
Objects of this class manage the print preview process.
__init__
(self, *args, **kw)¶__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.
printout (wx.Printout) –
printoutForPrinting (wx.Printout) –
data (wx.PrintDialogData) –
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)
printout (wx.Printout) –
printoutForPrinting (wx.Printout) –
data (wx.PrintData) –
GetCanvas
(self)¶Gets the preview window used for displaying the print preview image.
GetCurrentPage
(self)¶Gets the page currently being previewed.
int
GetFrame
(self)¶Gets the frame used for displaying the print preview canvas and control bar.
GetMaxPage
(self)¶Returns the maximum page number.
int
GetMinPage
(self)¶Returns the minimum page number.
int
GetPrintout
(self)¶Gets the preview printout object associated with the wx.PrintPreview object.
GetPrintoutForPrinting
(self)¶Gets the printout object to be used for printing from within the preview interface, or None
if none exists.
GetZoom
(self)¶Gets the current percentage zoom level of the preview canvas.
int
See also
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).
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.
canvas (wx.PreviewCanvas) –
dc (wx.DC) –
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.
prompt (bool) –
bool
RenderPage
(self, pageNum)¶Renders a page into a wx.MemoryDC.
Used internally by wx.PrintPreview.
pageNum (int) –
bool
SetCanvas
(self, window)¶Sets the window to be used for displaying the print preview image.
window (wx.PreviewCanvas) –
SetCurrentPage
(self, pageNum)¶Sets the current page to be previewed.
pageNum (int) –
bool
SetFrame
(self, frame)¶Sets the frame to be used for displaying the print preview canvas and control bar.
frame (wx.Frame) –
SetPrintout
(self, printout)¶Associates a printout object with the wx.PrintPreview object.
printout (wx.Printout) –
SetZoom
(self, percent)¶Sets the percentage preview zoom, and refreshes the preview canvas accordingly.
percent (int) –
See also
__bool__
(self)¶int
__nonzero__
(self)¶int
CurrentPage
¶See GetCurrentPage
and SetCurrentPage
MaxPage
¶See GetMaxPage
MinPage
¶See GetMinPage
Printout
¶See GetPrintout
and SetPrintout
PrintoutForPrinting
¶