Пример #1
0
 def Print(self, prompt=True, printer_name=None, orientation=None):
     """
     Print the pdf.
     
     :param boolean `prompt`: show the print dialog to the user (True/False). If
      False, the print dialog will not be shown and the pdf will be printed
      immediately. Default: True.
     :param string `printer_name`: the name of the printer that is to
      receive the printout. Default: as set by the O/S.
     :param `orientation`: select the orientation (wx.PORTRAIT or
      wx.LANDSCAPE) for the printout. Default: as set by the O/S.
     """
     pdd = wx.PrintDialogData()
     pdd.SetMinPage(1)
     pdd.SetFromPage(1)
     pdd.SetMaxPage(self.numpages)
     pdd.SetToPage(self.numpages)
     pdata = pdd.GetPrintData()
     if printer_name:
         pdata.SetPrinterName(printer_name)
     if orientation:
         pdata.SetOrientation(orientation)
     printer = wx.Printer(pdd)
     printout = pdfPrintout('', self)
     if (not printer.Print(self, printout, prompt=prompt) and
                    printer.GetLastError() == wx.PRINTER_ERROR):
         dlg = wx.MessageDialog(self, 'Unable to perform printing',
                           'Printer' , wx.OK | wx.ICON_INFORMATION)
         dlg.ShowModal()
         dlg.Destroy()
     printout.Destroy()
Пример #2
0
        def onPrint(self, event):
            race = Model.race
            if not race:
                return

            self.commit()

            mainWin = Utils.getMainWin()
            pd = mainWin.printData if mainWin else wx.PrintData()
            orientationSave = pd.GetOrientation()
            pd.SetOrientation(wx.PORTRAIT)

            pdd = wx.PrintDialogData(pd)
            pdd.SetAllPages(True)
            pdd.EnableSelection(False)
            pdd.EnablePageNumbers(False)
            pdd.EnableHelp(False)
            pdd.EnablePrintToFile(False)

            printer = wx.Printer(pdd)
            printout = FtpQRCodePrintout()

            if not printer.Print(self, printout, True):
                if printer.GetLastError() == wx.PRINTER_ERROR:
                    Utils.MessageOK(self,
                                    u'\n\n'.join([
                                        _("There was a printer problem."),
                                        _("Check your printer setup.")
                                    ]),
                                    _("Printer Error"),
                                    iconMask=wx.ICON_ERROR)

            pd.SetOrientation(orientationSave)
            printout.Destroy()
Пример #3
0
    def PrintButton(self, event):

        parent = self.print_canvas.GetTopLevelParent()

        pdd = wx.PrintDialogData(self.printData)
        pdd.SetToPage(1)
        printer = wx.Printer(pdd)

        ### copy in order to not change the size of original canvas when we rescal with zoom
        c = copy.copy(self.print_canvas)

        ### scale with A4 paper dim
        c.scalex = min(
            float(c.getWidth()) / 1654.0,
            float(c.getHeight()) / 2339.0)
        c.scaley = min(
            float(c.getWidth()) / 1654.0,
            float(c.getHeight()) / 2339.0)

        printout = Printout.Printout(c)

        if printer.Print(parent, printout, True):
            self.printData = wx.PrintData(
                printer.GetPrintDialogData().GetPrintData())
        printout.Destroy()
Пример #4
0
    def print_setup(self, evt):
        '''Print'''
        foo = cgi.escape(self.tab_list[self.current_tab].GetText())
        testo = replace(foo, "\n", "<br>")
        testo = replace(testo, "\r\n", "<br>")
        testo = replace(testo, " ", " &nbsp;")
        testo = replace(testo, "\t", " &nbsp;&nbsp;&nbsp;&nbsp;")

        self.printData = wx.PrintData()
        self.printData.SetPaperId(wx.PAPER_A4)
        pdd = wx.PrintDialogData()
        pdd.SetPrintData(self.printData)

        pdd.EnablePrintToFile(0)
        pdd.SetMinPage(1)
        pdd.SetMaxPage(5)
        pdd.SetAllPages(True)
        dlg = wx.PrintDialog(self, pdd)
        if dlg.ShowModal() == wx.ID_OK:
            pdd = dlg.GetPrintDialogData()
        else:
            dlg.Destroy()
            return
        dlg.Destroy()
        printer = wx.Printer(pdd)
        printout = wx.HtmlPrintout(
            title=str(self.tab_list[self.current_tab].dir_to_file))
        printout.SetMargins(top=15, bottom=15, left=13, right=13)
        printout.SetHtmlText(testo)
        printer.Print(self, printout, prompt=FALSE)
        printout.Destroy()
Пример #5
0
    def printout(self, print_area, print_data):
        """Print out print area

        See:
        http://aspn.activestate.com/ASPN/Mail/Message/wxpython-users/3471083

        """

        print_info = \
            self.main_window.interfaces.get_cairo_export_info("Print")

        if print_info is None:
            # Dialog has been canceled
            return

        pdd = wx.PrintDialogData(print_data)
        printer = wx.Printer(pdd)

        printout = Printout(self.grid, print_data, print_info)

        if printer.Print(self.main_window, printout, True):
            self.print_data = \
                wx.PrintData(printer.GetPrintDialogData().GetPrintData())

        printout.Destroy()
Пример #6
0
 def print_figure(self, event):
     try:
         _printer = wx.Printer()
         _printer.Print(self.canvas, PlotPrintout(self.canvas), True)
     except:
         import traceback
         logging.error(traceback.format_exc())
Пример #7
0
	def OnPrint( self, event ):
		try:
			bitmap = wx.Bitmap( self.thumbFileName, wx.BITMAP_TYPE_JPEG )
		except:
			Utils.MessageOK( self, _('No Photo Available.'), _('Print Failed'), iconMask = wx.ICON_ERROR )
			return
		
		if Utils.mainWin:
			pdd = wx.PrintDialogData(Utils.mainWin.printData)
		else:
			printData = wx.PrintData()
			printData.SetPaperId(wx.PAPER_LETTER)
			printData.SetPrintMode(wx.PRINT_MODE_PRINTER)
			printData.SetOrientation(wx.LANDSCAPE)
			pdd = wx.PrintDialogData(printData)
			
		pdd.SetAllPages( 1 )
		pdd.EnablePageNumbers( 0 )
		pdd.EnableHelp( 0 )
		
		printer = wx.Printer(pdd)
		printout = PhotoPrintout( getRiderNameFromFName(self.thumbFileName), self.thumbFileName )

		if not printer.Print(self, printout, True):
			if printer.GetLastError() == wx.PRINTER_ERROR:
				Utils.MessageOK(self, u'\n\n'.join( [_("There was a printer problem."), _('Check your printer setup.')] ), _("Printer Error"), iconMask=wx.ICON_ERROR)
		else:
			self.printData = wx.PrintData( printer.GetPrintDialogData().GetPrintData() )

		printout.Destroy()
Пример #8
0
    def menuPrint(self, event):
        self.commit()
        title = self.getTitle()
        page = self.pages[self.notebook.GetSelection()]
        try:
            grid = page.getGrid()
            printout = SeriesMgrPrintout(title, grid)
        except AttributeError:
            if page == self.graphDraw:
                printout = GraphDrawPrintout(title, page)
            else:
                return

        pdd = wx.PrintDialogData(self.printData)
        pdd.EnablePageNumbers(0)
        pdd.EnableHelp(0)

        printer = wx.Printer(pdd)

        if not printer.Print(self, printout, True):
            if printer.GetLastError() == wx.PRINTER_ERROR:
                Utils.MessageOK(
                    self,
                    "There was a printer problem.\nCheck your printer setup.",
                    "Printer Error",
                    iconMask=wx.ICON_ERROR)
        else:
            self.printData = wx.PrintData(
                printer.GetPrintDialogData().GetPrintData())

        printout.Destroy()
Пример #9
0
def PrintCategories():
    mainWin = Utils.getMainWin()
    race = Model.race
    if not mainWin or not race:
        return

    pdd = wx.PrintDialogData(mainWin.printData)
    pdd.EnableSelection(False)
    pdd.EnablePageNumbers(False)
    pdd.EnableHelp(False)
    pdd.EnablePrintToFile(False)

    printer = wx.Printer(pdd)
    printout = CategoriesPrintout()

    if not printer.Print(mainWin, printout, True):
        if printer.GetLastError() == wx.PRINTER_ERROR:
            Utils.MessageOK(mainWin,
                            u'\n\n'.join([
                                _("There was a printer problem."),
                                _("Check your printer setup.")
                            ]),
                            _("Printer Error"),
                            iconMask=wx.ICON_ERROR)
    else:
        mainWin.printData = wx.PrintData(
            printer.GetPrintDialogData().GetPrintData())

    printout.Destroy()
Пример #10
0
def PrintPhoto(parent, image):
    printData = wx.PrintData()
    printData.SetPaperId(wx.PAPER_LETTER)
    printData.SetPrintMode(wx.PRINT_MODE_PRINTER)
    printData.SetOrientation(wx.LANDSCAPE)

    pdd = wx.PrintDialogData(printData)
    pdd.EnableSelection(False)
    pdd.EnablePageNumbers(False)
    pdd.EnableHelp(False)
    pdd.EnablePrintToFile(False)

    printer = wx.Printer(pdd)
    printout = PhotoPrintout(image)

    if not printer.Print(parent, printout, True):
        if printer.GetLastError() == wx.PRINTER_ERROR:
            wx.MessageBox(
                u'\n\n'.join([
                    _("There was a printer problem."),
                    _("Check your printer setup.")
                ]), _("Printer Error"))
    else:
        printData = wx.PrintData(printer.GetPrintDialogData().GetPrintData())

    printout.Destroy()
Пример #11
0
    def Print(self):
        '''Print(self) --> None

        Prints the values to the printer
        '''
        pd = wx.PrintData()
        pd.SetPrinterName('')
        pd.SetOrientation(wx.LANDSCAPE)
        pd.SetPaperId(wx.PAPER_A4)
        pd.SetQuality(wx.PRINT_QUALITY_DRAFT)
        pd.SetColour(True)
        pd.SetNoCopies(1)
        pd.SetCollate(True)

        pdd = wx.PrintDialogData()
        pdd.SetPrintData(pd)
        pdd.SetMinPage(1)
        pdd.SetMaxPage(1)
        pdd.SetFromPage(1)
        pdd.SetToPage(2)
        pdd.SetPrintToFile(True)

        printer = wx.Printer(pdd)
        self._update_printer()
        self.prt.Print()
Пример #12
0
 def print_plot(self, evt):
     printout = backend_wx.PrintoutWx(self.canvas)
     dialog_data = wx.PrintDialogData()
     compat_wx.configure_print_dialog_data(dialog_data)
     printer = wx.Printer(dialog_data)
     if not printer.Print(self, printout, True):
         if printer.GetLastError() == wx.PRINTER_ERROR:
             gui_util.message("A printing error occurred.")
Пример #13
0
 def Menu109(self, evt):
     p = self.nb.GetSelection()
     # self.docs[p].
     print "printing"
     pdd = wx.PrintDialogData(self.pd)
     printer = wx.Printer(pdd)
     ToBePrinted = self.docs[p]
     self.pd = wx.PrintData( printer.GetPrintDialogData().GetPrintData() )
     ToBePrinted.Destroy()
Пример #14
0
 def Print(self):
     pdd = wx.PrintDialogData(self.printData)
     printer = wx.Printer(pdd)
     printout = SetPrintout(self)
     if not printer.Print(self.parentFrame, printout):
         wx.MessageBox("There was a problem printing.\nPerhaps your current printer is not set correctly?", "Printing", wx.OK)
     else:
         self.printData = wx.PrintData( printer.GetPrintDialogData().GetPrintData() )
     printout.Destroy()
Пример #15
0
    def PrintNetwork(self):
        img = self._GetExportImage()
        if not img:
            return

        # Pass two printout objects: for preview, and possible printing.
        printer = wx.Printer()
        printout = NetworkPrintout(img)
        printer.Print(self, printout, True)
Пример #16
0
 def PrintText(self, htmltext, basepath="", scale=1.0):
     pdd=wx.PrintDialogData()
     if self.printData.Ok():
         pdd.SetPrintData(self.printData.copy())
     if not pdd.GetPrintData().Orientation:
         pdd.GetPrintData().SetOrientation(wx.PORTRAIT)
     printer=wx.Printer(pdd)
     with guihelper.WXDialogWrapper(self._getprintout(htmltext, basepath, scale)) \
          as printout:
         printer.Print(self.parent, printout)
Пример #17
0
 def run_printdlg(self, win, printout):
     printout.shifts = () + self.shifts
     print_data = get_print_data(self.app)
     print_data.SetPrinterName(self.name)
     print_data.SetColour(self.color_mode == COLOR_MODE)
     print_data.SetCollate(self.collate)
     print_data.SetNoCopies(self.copies)
     data = wx.PrintDialogData(print_data)
     data.EnablePageNumbers(False)
     printer = wx.Printer(data)
     return printer.Print(win, printout, True)
Пример #18
0
 def print_plot(self, evt):
     printout = backend_wx.PrintoutWx(self.canvas)
     dialog_data = wx.PrintDialogData()
     if wx.VERSION < (2, 5):
         dialog_data.EnableHelp(False)
         dialog_data.EnablePageNumbers(False)
         dialog_data.EnableSelection(False)
     printer = wx.Printer(dialog_data)
     if not printer.Print(self, printout, True):
         if printer.GetLastError() == wx.PRINTER_ERROR:
             gui_util.message("A printing error occurred.")
Пример #19
0
 def printFigure(self, figure, title=None):
     """
     Replace wxmpl.FigurePrinter.printFigure method
     """
     pdData = wx.PrintDialogData()
     pdData.SetPrintData(self.printer.pData)
     pdData.SetToPage(1)  # Fix for wxmpl version 2.0dev
     printer = wx.Printer(pdData)
     fpo = FigurePrintout(figure, title)
     if printer.Print(self.printer.view, fpo, True):
         self.printer.pData = pdData.GetPrintData()
Пример #20
0
    def OnDoPrint(self, event):
        pdd = wx.PrintDialogData(self.printData)
        pdd.SetToPage(2)
        printer = wx.Printer(pdd)
        printout = MyPrintout(self.canvas, self.log)

        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 = wx.PrintData( printer.GetPrintDialogData().GetPrintData() )
        printout.Destroy()
Пример #21
0
 def printout(self, paper=None):
     """Print current plot."""
     if paper != None:
         self.print_data.SetPaperId(paper)
     pdd = wx.PrintDialogData()
     pdd.SetPrintData(self.print_data)
     printer = wx.Printer(pdd)
     out = graph_printout(self)
     print_ok = printer.Print(self.parent, out)
     if print_ok:
         self.print_data = printer.GetPrintDialogData().GetPrintData()
     out.Destroy()
Пример #22
0
    def OnPrint(self, event):
        printData = wx.PrintData()
        printData.SetPaperId(wx.PAPER_LETTER)
        printData.SetPrintMode(wx.PRINT_MODE_PRINTER)
        pdd = wx.PrintDialogData(printData)
        printer = wx.Printer(pdd)
        printout = MyPrintout(self)

        if not printer.Print(self.parent, printout, True):
            wx.MessageBox("There was a problem printing.\nPerhaps your current printer is not set correctly?", "Printing", wx.OK)
        else:
            printData = wx.PrintData( printer.GetPrintDialogData().GetPrintData() )
        printout.Destroy()
Пример #23
0
    def OnDoPrint(self, event):
        pdd = wx.PrintDialogData()
        pdd.SetPrintData(self.printData)
        printer = wx.Printer(pdd)
        printout = self.createSTCPrintout()

        if not printer.Print(self.parentFrame, printout):
            wx.LogError(_('An error occured while printing.'))
        else:
            self.printData = wx.PrintData(printer.GetPrintDialogData().GetPrintData())
        printout.Destroy()

        self.EndModal(wx.OK)
Пример #24
0
    def OnDoPrint(self, event):
        pdd = wx.PrintDialogData(self.m_pd)
        pdd.SetToPage(2)
        printer = wx.Printer(pdd)
        printout = self.m_po(self.m_canvas)

        if not printer.Print(self.m_parent, printout, True):
            #wx.MessageBox(message('print_errprinting'), message('print_printing'), wx.OK)
            pass
        else:
            self.m_pd = wx.PrintData(
                printer.GetPrintDialogData().GetPrintData())
        printout.Destroy()
    def doPrint(self, printer, wikiDocument, wordList, printType, addopt):
        self.setContext(printer, wikiDocument, wordList, printType, addopt)
        text = self._buildHtml()

        try:
            printout = HtmlPrintout(text, self.printer)

            pData = wx.PrintDialogData(self.printer.getPrintData())
            printer = wx.Printer(pData)

            return printer.Print(self.mainControl, printout, True)
        finally:
            self._freeHtml()
Пример #26
0
 def OnDoPrint(self, event=None):
     pdd = wx.PrintDialogData(self.printData)
     pdd.SetToPage(2)
     printer = wx.Printer(pdd)
     printout = Printout(self)
     if not printer.Print(self.frame, printout, True):
         wx.MessageBox(
             "Printing was cancelled.\n\nIf you didn't cancel the print, perhaps\nyour current printer is not set correctly?",
             "Printing", wx.OK)
     else:
         self.printData = wx.PrintData(
             printer.GetPrintDialogData().GetPrintData())
     printout.Destroy()
Пример #27
0
	def onPrintInstr(self, evt):
		pdd = wx.PrintDialogData(self.printData)
		pdd.SetToPage(2)
		printer = wx.Printer(pdd)
		printout = PBInstructionsPrint(self.pb)

		if not printer.Print(self, printout, True):
			rc = printer.GetLastError()
			if rc == wx.PRINTER_ERROR:
				wx.MessageBox("There was a problem printing.\nPerhaps your current printer is not set correctly?", "Printing", wx.OK)
		else:
			self.printData = wx.PrintData( printer.GetPrintDialogData().GetPrintData() )
		printout.Destroy()
Пример #28
0
    def DoPrint(self, parent=None):
        """
        Send the report to the configured printer
        """
        pdd = wx.PrintDialogData(self.printData)
        printer = wx.Printer(pdd)

        if printer.Print(parent, self, True):
            self.printData = wx.PrintData(printer.GetPrintDialogData().GetPrintData())
        else:
            wx.MessageBox("There was a problem printing.\nPerhaps your current printer is not set correctly?", "Printing", wx.OK)

        printout.Destroy()
Пример #29
0
 def Print(self, editor):
     data = wx.PrintDialogData(self.pdata)
     printer = wx.Printer(data)
     printout = Printout(editor, self.margins)
     printed = printer.Print(editor._frame, printout)
     if printed:
         self.pdata = wx.PrintData(
             printer.GetPrintDialogData().GetPrintData())
     elif printer.GetLastError() == wx.PRINTER_ERROR:
         wx.MessageBox(
             _("'%s' could not be printed.\nMake sure that your printer is connected properly."
               ) % editor.filename, _("Print"), wx.ICON_ERROR | wx.OK)
     printout.Destroy()
Пример #30
0
 def OnPrint(self, e):
     printDialogData = wx.PrintDialogData(self.printData)
     printer = wx.Printer(printDialogData)
     self.printout = Printout()
     if printer.Print(self.frame, self.printout, True):
         self.printData = printer.GetPrintDialogData().GetPrintData()
     else:
         if wx.Printer.GetLastError() == wx.PRINTER_ERROR:
             wx.MessageBox('There was a problem printing.\nPerhaps your current printer is not set correctly?', 'Printing', wx.OK)
         else:
             wx.MessageBox('You canceled printing', 'Printing', wx.OK)
             
     self.printout = None