The Print() method takes the following parameters:
Print(parent, printout, prompt=True).
The parent instance is a window to use as the parent window for any dialogs that are triggered while printing. The printout is your wx.Printout object to print. If prompt is True, the printer dialog box is displayed before printing, otherwise printing will start immediately.
The Print() method returns True if printing was successful. If not, you can call the printer method GetLastError() and get back one of the constants wx.PRlNTER_CANCELLED (if the failure was due to the user canceling printing), wx.PRlNTER_ERROR (if the failure occurred during the printing itself), or wx.PRlNTER_NO_ERROR (if Print() returned True and nothing went wrong. There are two other things you can do with a wx.Printer instance:
■ You can display the abort dialog box with CreateAbortWindow(parent, printout), where parent and printout are as in the Print() method. If the user has aborted the print job, you can find out by calling the Abort() method, which will return True in that case.
■ You can explicitly display the print dialog with PrintDialog(parent), and you can retrieve the active print data object with GetPrintDialogData().
Was this article helpful?