X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/d7403ad2d154a8e2974fdc5fc215258f3a75cdde..bc50a2ae95f2ab36b16ceedc7902a9cbfb2f70ea:/wxPython/demo/PrintFramework.py diff --git a/wxPython/demo/PrintFramework.py b/wxPython/demo/PrintFramework.py index 0bf389a6ae..6aa0b5700f 100644 --- a/wxPython/demo/PrintFramework.py +++ b/wxPython/demo/PrintFramework.py @@ -15,38 +15,38 @@ class MyPrintout(wx.Printout): self.log = log def OnBeginDocument(self, start, end): - self.log.WriteText("wx.Printout.OnBeginDocument\n") - return self.base_OnBeginDocument(start, end) + self.log.WriteText("MyPrintout.OnBeginDocument\n") + return super(MyPrintout, self).OnBeginDocument(start, end) def OnEndDocument(self): - self.log.WriteText("wx.Printout.OnEndDocument\n") - self.base_OnEndDocument() + self.log.WriteText("MyPrintout.OnEndDocument\n") + super(MyPrintout, self).OnEndDocument() def OnBeginPrinting(self): - self.log.WriteText("wx.Printout.OnBeginPrinting\n") - self.base_OnBeginPrinting() + self.log.WriteText("MyPrintout.OnBeginPrinting\n") + super(MyPrintout, self).OnBeginPrinting() def OnEndPrinting(self): - self.log.WriteText("wx.Printout.OnEndPrinting\n") - self.base_OnEndPrinting() + self.log.WriteText("MyPrintout.OnEndPrinting\n") + super(MyPrintout, self).OnEndPrinting() def OnPreparePrinting(self): - self.log.WriteText("wx.Printout.OnPreparePrinting\n") - self.base_OnPreparePrinting() + self.log.WriteText("MyPrintout.OnPreparePrinting\n") + super(MyPrintout, self).OnPreparePrinting() def HasPage(self, page): - self.log.WriteText("wx.Printout.HasPage: %d\n" % page) + self.log.WriteText("MyPrintout.HasPage: %d\n" % page) if page <= 2: return True else: return False def GetPageInfo(self): - self.log.WriteText("wx.Printout.GetPageInfo\n") + self.log.WriteText("MyPrintout.GetPageInfo\n") return (1, 2, 1, 2) def OnPrintPage(self, page): - self.log.WriteText("wx.Printout.OnPrintPage: %d\n" % page) + self.log.WriteText("MyPrintout.OnPrintPage: %d\n" % page) dc = self.GetDC() #------------------------------------------- @@ -128,9 +128,14 @@ class TestPrintPanel(wx.Panel): def OnPrintSetup(self, event): data = wx.PrintDialogData(self.printData) printerDialog = wx.PrintDialog(self, data) - printerDialog.GetPrintDialogData().SetSetupDialog(True) + #printerDialog.GetPrintDialogData().SetSetupDialog(True) printerDialog.ShowModal(); - self.printData = printerDialog.GetPrintDialogData().GetPrintData() + + # this makes a copy of the wx.PrintData instead of just saving + # a reference to the one inside the PrintDialogData that will + # be destroyed when the dialog is destroyed + self.printData = wx.PrintData( printerDialog.GetPrintDialogData().GetPrintData() ) + printerDialog.Destroy() @@ -163,7 +168,7 @@ class TestPrintPanel(wx.Panel): if not printer.Print(self.frame, printout, True): wx.MessageBox("There was a problem printing.\nPerhaps your current printer is not set correctly?", "Printing", wx.OK) else: - self.printData = printer.GetPrintDialogData().GetPrintData() + self.printData = wx.PrintData( printer.GetPrintDialogData().GetPrintData() ) printout.Destroy()