Summary

■ There is a general print framework in wxPython which goes beyond merely printing HTML to allow you to print anything that can be drawn to a device context. The main class in this framework is wx.Printout, but wx.Printer and wx.PrintPreview are also prominent.

■ The wx.Printout class manages the graphical details of your print, and includes several lifecycle methods which can be overridden to customize the behavior and data used during your print session. The printing takes place during the method OnPrintPage().

■ The standard dialogs for printer setup and page setup are accessible from wxPython. The printer setup dialog is an instance of wx.PrintDialog, and the page setup dialog is an instance of wx.PageSetupDialog. Both dialogs have associated data classes that allow your program to manipulate all the values displayed in the dialogs.

■ Once the data is in place, actually sending it to the printer is a relatively straightforward application of the wx.Printer class. You can use the wx.PrintPreview class to manage a print preview session, which includes a print preview frame, and the option to specify normal printing behavior from that frame.

Was this article helpful?

0 0

Post a comment