Hey,
I am trying to print more then one page via wxPrintout class. At the top of each page I want to write some kine of a header.
The problem is that it print the header and nothing more. The code goes like this (the code is runnable):
from wxPython.wx import *
class MyPrintout(wxPrintout):
def __init__(self, title):
wxPrintout.__init__(self, title)
self.dc = NULL
def OnBeginPrinting(self):
self.base_OnBeginPrinting()
self.dc = self.GetDC()
self.PrintBody() #Printing the main body
# Printing the header of new document
def OnBeginDocument(self, start, end):
self.base_OnBeginDocument(start, end)
self.dc.DrawText('THIS IS A NEW DOCUMENT', 10, 10)
return true
# Printing the header of new page
def OnPrintPage(self, page):
self.dc.DrawText('THIS IS A NEW PAGE', 10, 60)
return true
# Printing the main body
def PrintBody(self):
self.dc.DrawText('THIS IS THE MAIN BODY', 10, 110)
return true
if __name__ == '__main__':
app = wxPySimpleApp()
frame = wxFrame(None, wxNewId(), 'PRINTING')
printout = MyPrintout('PRINTING')
printData = wxPrintData()
printData.SetPaperId(wxPAPER_LETTER)
pdd = wxPrintDialogData()
pdd.SetPrintData(printData)
printer = wxPrinter(pdd)
printer.Print(frame, printout)
printout.Destroy()
app.MainLoop()
···
_________________________________________________________________