Hello everybody,
i have a problem with the printing framework of wpython.
I wrote a print class and now I'm having a problem setting up the desired paper size and margins correctly. My paper size and margin settings are just fully ignored.
My goal is to print on a paper without having margins.
I have no idea what I'm doing wrong
Does anybody have an idea?
My class looks like follows:
class printing:
def __init__(self, parent):
#parent is of type wx.frame
self.parent = parent
self.printData = wx.PrintData()
def customPageSetup(self):
self.printData.SetDuplex(wx.DUPLEX_SIMPLEX)
self.printData.SetOrientation(wx.PORTRAIT)
self.printData.SetPaperSize((100, 100))
def OnPrintSetup(self, event=None):
self.customPageSetup()
printDialogData = wx.PrintDialogData()
printDialogData.SetMaxPage(1)
printDialog = wx.PrintDialog(self.parent, data=printDialogData)
if printDialog.ShowModal() == wx.ID_OK:
printDialogData = printDialog.GetPrintDialogData()
self.printData = wx.PrintData(printDialogData.GetPrintData())
printDialog.Destroy()
return True
def OnPageSetup(self, event=None):
self.customPageSetup()
pageSetupDialogData = wx.PageSetupDialogData()
pageSetupDialogData.SetPaperSize((100, 100))
pageSetupDialogData.SetDefaultMinMargins(False)
pageSetupDialogData.SetMarginTopLeft((0, 0))
pageSetupDialogData.SetMinMarginBottomRight((0, 0))
pageSetupDialog = wx.PageSetupDialog(self.parent, data=pageSetupDialogData)
if pageSetupDialog.ShowModal() == wx.ID_OK:
pageSetupDialogData = pageSetupDialog.GetPageSetupDialogData()
self.printData = wx.PrintData(pageSetupDialogData.GetPrintData())
pageSetupDialog.Destroy()
return True
def OnPrintPreview(self, event=None):
self.customPageSetup()
printout = MyPrintout(self.parent)
printoutForPrinting = MyPrintout(self.parent)
preview = wx.PrintPreview(printout, printoutForPrinting, self.printData)
previewFrame = wx.PreviewFrame(preview, self.parent, "some title")
previewFrame.Initialize()
previewFrame.Show()
return True
def OnDoPrint(self, event=None):
self.customPageSetup()
printout = MyPrintout(self.parent)
printer = wx.Printer(data=None)
printer.Print(self.parent, printout, prompt=True)
printout.Destroy()
return True
cu alex