How do I print in wxPython

We'll start with the wx.Printout class. Like frames, and unlike many of the widget classes, you'll create your own custom subclass of wx.Printout. Next, you will override methods of wx.Printout to define your custom printing behavior. There are seven methods of wx.Printout that you can override to customize how the printout object does its work. These methods are automatically called by wxPython during the course of a printing session. Figure 17.1 displays six of these methods c

Printing "N Starts J

OnPreparePrintingO

Printing "N Starts J

OnPreparePrintingO

1

r

OnBeginPrintingQ

r

OnBeginDocumentQ <

For each page

For each page

For each copy

OnEndDocumentQ

T

OnEndF

'rintingO

f Printing ^ Ends J

f Printing ^ Ends J

Figure 17.1 The lifecycle of a printout showing all the methods automatically called by wxPython that are triggered by specific events. In most cases you will not need to overwrite all of them.

Was this article helpful?

0 0

Post a comment