def OnDoPrint(self, event=None): self.OnSave() self.customPageSetup() #Set data to print printout = Printout(self) #Instance of printer class printer = wx.Printer(data=None) #Print #This processes the methods of printout if not printer.Print(self, printout, prompt=True) \ and printer.GetLastError() == wx.PRINTER_ERROR: wx.MessageBox( _(u"There was a problem printing.\nPerhaps your current printer is not set correctly?" ), _(u"Printing Error"), wx.OK) else: data = printer.GetPrintDialogData() self.pdata = wx.PrintData(data.GetPrintData()) printout.Destroy() return True
def OnPrintPreview(self, event=None): self.OnSave() self.__customPageSetup() #Set data to print printout = Printout(self) printoutForPrinting = Printout(self) preview = wx.PrintPreview(printout, printoutForPrinting, self.printData) if not preview.Ok(): wx.MessageBox(_(u"Unable to create Print Preview!"), _(u"Preview Error")) else: previewFrame = wx.PreviewFrame(preview, self, _(u"Print Preview"), pos=self.GetPosition(), size=self.GetSize()) previewFrame.Initialize() previewFrame.Show() return True
def print_calibration(self, app, win, path, media=''): pd = ProgressDialog(_('Loading calibration page...'), win) try: loader = get_loader(path) doc_presenter = pd.run(loader, [app.appdata, path]) self.run_printdlg(win, Printout(doc_presenter)) except Exception: txt = _('Error while printing of calibration page!') txt += '\n' + _('Check your printer status and connection.') error_dialog(win, app.appdata.app_name, txt) finally: pd.destroy()
def print_calibration(self, app, win, path, media=''): doc_presenter = None loader = get_loader(path) pd = ProgressDialog(_('Loading calibration page...'), win) ret = pd.run(loader, [app.appdata, path]) if ret and pd.result is not None: doc_presenter = pd.result if doc_presenter: try: self.printing(Printout(doc_presenter), media) except: doc_presenter = None pd.destroy() if not doc_presenter: txt = _('Error while printing of calibration page!') txt += '\n' + _('Check your printer status and connection.') error_dialog(win, app.appdata.app_name, txt)