def OnPrint(self, event): """ Event Handler for Printing """ # If we're using the Rich Text Control ... if TransanaConstants.USESRTC: # Define the FONT for the Header and Footer text headerFooterFont = wx.Font(10, wx.FONTFAMILY_ROMAN, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False, "Times New Roman") # Get the current date and time t = time.localtime() # Format the Footer Date as M/D/Y footerDate = "%d/%d/%d" % (t.tm_mon, t.tm_mday, t.tm_year) # Format the Footer Page Number footerPage = _("Page") + " @PAGENUM@ " + _("of") + " @PAGESCNT@" # Create a RichTextPrinting Object printout = richtext.RichTextPrinting(_("Transana Report"), self) # Let the printout know about the default printer settings printout.SetPrintData(self.printData) # Specify the Header / Footer Font printout.SetHeaderFooterFont(headerFooterFont) # Add the Report Title to the top right printout.SetHeaderText(self.title, location=richtext.RICHTEXT_PAGE_RIGHT) # Add the date to the bottom left printout.SetFooterText(footerDate, location=richtext.RICHTEXT_PAGE_LEFT) # Add the page number to the bottom right printout.SetFooterText(footerPage, location=richtext.RICHTEXT_PAGE_RIGHT) # Do NOT show Header and Footer on the First Page printout.SetShowOnFirstPage(False) # print the RTC Buffer Contents printout.PrintBuffer(self.reportText.GetBuffer()) # Destroy the RichTextPrinting Object printout.Destroy()
def Print(self, event): if self.win.GetFilename() != '': self.printer = text.RichTextPrinting() self.printer.GetPrintData() self.printer.PrintFile(self.win.GetFilename())
def OnPrint(self, evt): rtPrinting = rt.RichTextPrinting(parentWindow=self) rtPrinting.GetPageSetupData().SetMarginTopLeft((10.0, 10.0)) rtPrinting.GetPageSetupData().SetMarginBottomRight((10.0, 10.0)) rtPrinting.PrintBuffer(self.rtc.GetBuffer())