The first step in a print preview is creating an instance of the class wx.PrintPre-view, which is analogous to wx.Printer. Here is the constructor.
wx.PrintPreview(printout, printoutForPrinting, data=None)
Notice that where the wx.Printer instance took the parent window in the constructor, and the printout in the printing method, wx.PrintPreview handles the printout in the constructor. The first parameter to the constructor is printout, the wx.Printout object used to manage the preview. The printoutForPrinting parameter is another wx.Printout object. If it is not None, the print preview window, when displayed, contains a Print button that starts the print to the printer process. The printoutForPrinting printout object is used for the actual print. If the printoutForPrinting parameter is None, the button is not displayed. Of course, there is nothing preventing you from passing the same instance to both printout and printoutForPrinting, or from having both instances being identical versions of your custom printout class. The data parameter is either a wx.PrintData object or a wx.PrintDialogData object. If specified, it is used to control the print preview. In listing 17.1, we displayed an example of using a print preview in the OnPrintPreview() method of the window.
Was this article helpful?