Esempio n. 1
0
    def OnPrintSetup(self, event):
        data = wx.PrintDialogData(self.printData)
        printerDialog = wx.PrintDialog(self, data)
        printerDialog.GetPrintDialogData().SetSetupDialog(True)
        printerDialog.ShowModal()

        # this makes a copy of the wx.PrintData instead of just saving
        # a reference to the one inside the printDialogData that will
        # be destroyed
        self.printData = wx.PrintData(
            printerDialog.GetPrintDialogData().GetPrintData())

        printerDialog.Destroy()
Esempio n. 2
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()
Esempio n. 3
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)
Esempio n. 4
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()
Esempio n. 5
0
    def OnPageSetup(self, event):
        self.setup()
        psdd = wx.PageSetupDialogData(self.printData)
        psdd.CalculatePaperSizeFromId()
        dlg = wx.PageSetupDialog(self.mapwin, psdd)
        dlg.ShowModal()

        # 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(dlg.GetPageSetupData().GetPrintData())

        dlg.Destroy()
Esempio n. 6
0
    def printSizes(self, filename):
        """ Export the Canvas to Postscript """
        prdata = wx.PrintData()
        from Explorers.Explorer import openEx
        t = openEx(filename)
        prdata.SetFilename(t.currentFilename())
        dc = wx.PostScriptDC(prdata)
        if dc.Ok():
            dc.StartDoc('Export')
            self.Redraw(dc)
            dc.EndDoc()

            wx.LogMessage('Exported %s' % filename)
Esempio n. 7
0
    def test_nonzero(self):
        psdd = wx.PageSetupDialogData()
        pd = wx.PrintData()
        pdd = wx.PrintDialogData()

        if six.PY3:
            psdd.__bool__()
            pd.__bool__()
            pdd.__bool__()
        else:
            psdd.__nonzero__()
            pd.__nonzero__()
            pdd.__nonzero__()
Esempio n. 8
0
    def __init__(self):
        wx.Frame.__init__(self,
                          None,
                          size=(640, 480),
                          title="Print Framework Sample")
        self.CreateStatusBar()

        # A text widget to display the doc and let it be edited
        self.tc = wx.TextCtrl(self,
                              -1,
                              "",
                              style=wx.TE_MULTILINE | wx.TE_DONTWRAP)
        self.tc.SetFont(
            wx.Font(FONTSIZE, wx.FONTFAMILY_TELETYPE, wx.FONTSTYLE_NORMAL,
                    wx.FONTWEIGHT_NORMAL))
        filename = os.path.join(os.path.dirname(__file__), "sample-text.txt")
        with open(filename) as fid:
            self.tc.SetValue(fid.read())
        self.tc.Bind(wx.EVT_SET_FOCUS, self.OnClearSelection)
        wx.CallAfter(self.tc.SetInsertionPoint, 0)

        # Create the menu and menubar
        menu = wx.Menu()
        item = menu.Append(-1, "Page Setup...\tF5",
                           "Set up page margins and etc.")
        self.Bind(wx.EVT_MENU, self.OnPageSetup, item)
        item = menu.Append(-1, "Print Preview...\tF6",
                           "View the printout on-screen")
        self.Bind(wx.EVT_MENU, self.OnPrintPreview, item)
        item = menu.Append(-1, "Print...\tF7", "Print the document")
        self.Bind(wx.EVT_MENU, self.OnPrint, item)
        menu.AppendSeparator()
        ##         item = menu.Append(-1, "Test other stuff...\tF9", "")
        ##         self.Bind(wx.EVT_MENU, self.OnPrintTest, item)
        ##         menu.AppendSeparator()

        item = menu.Append(wx.ID_ABOUT, "About", "About this application")
        self.Bind(wx.EVT_MENU, self.OnAbout, item)
        item = menu.Append(wx.ID_EXIT, "E&xit\tCtrl-Q",
                           "Close this application")
        self.Bind(wx.EVT_MENU, self.OnExit, item)

        menubar = wx.MenuBar()
        menubar.Append(menu, "&File")
        self.SetMenuBar(menubar)

        # initialize the print data and set some default values
        self.pdata = wx.PrintData()
        self.pdata.SetPaperId(wx.PAPER_LETTER)
        self.pdata.SetOrientation(wx.PORTRAIT)
        self.margins = (wx.Point(15, 15), wx.Point(15, 15))
Esempio n. 9
0
 def OnInit(self):
     self.RegisterMessageBoxCallback()
     self.InitCad()
     self.RegisterObjectTypes()
     
     self.printData = wx.PrintData()
     self.pageSetupData = wx.PageSetupDialogData(self.printData)
         
     wx.InitAllImageHandlers()
     
     # Turn on high-DPI awareness to make sure rendering is sharp on big
     # monitors with font scaling enabled.
     from ctypes import OleDLL
     OleDLL('shcore').SetProcessDpiAwareness(1)
     
     config = HeeksConfig()
     
     width = config.ReadInt('MainFrameWidth', -1);
     height = config.ReadInt('MainFrameHeight', -1);
     x = config.ReadInt('MainFramePosX', -1);
     y = config.ReadInt('MainFramePosY', -1);
     
     if width < 0:
         width = -1
         height = -1
         x = -1
         y = -1
     else:
         stored_rect = wx.Rect(x, y, width, height)
         in_display = False
         for idx in range(wx.Display.GetCount()):
             d = wx.Display(idx)
             rect = d.GetGeometry()
             if rect.Contains(wx.Point(x, y)):
                 in_display = True
         if in_display == False:
             width = -1
             height = -1
             x = -1
             y = -1
             
     self.LoadConfig()
     
     self.frame = self.NewFrame(wx.Point(x, y), wx.Size(width, height))
     self.frame.Show()
     self.OnNewOrOpen(False)
     cad.ClearHistory()
     cad.SetLikeNewFile()
     self.frame.SetFrameTitle()
     
     return True
Esempio n. 10
0
 def __init__(self,
              parent=None,
              id=-1,
              title='',
              pos=wx.DefaultPosition,
              size=default_size,
              visible=1):
     wx.Frame.__init__(self, parent, id, title, pos, size)
     # seb-20040824 wx.EVT_CLOSE(self, self.OnCloseWindow) #added by BEC
     # Now Create the menu bar and items
     self.mainmenu = wx.MenuBar()
     menu = wx.Menu()
     menu.Append(200, '&Save As...', 'Save plot to image file')
     wx.EVT_MENU(self, 200, self.file_save_as)
     menu.Append(
         202, '&Save As CSV (column order)...',
         'Save plot to CSV (tab separated, datasets in columns) text file')
     wx.EVT_MENU(self, 202,
                 lambda ev: self.file_save_csv(ev, transpose=True))
     menu.Append(
         201, '&Save As CSV (row order)...',
         'Save plot to CSV (tab separated, datasets in rows) text file')
     wx.EVT_MENU(self, 201, self.file_save_csv)
     menu.Append(203, '&Print...', 'Print the current plot')
     wx.EVT_MENU(self, 203, self.file_print)
     menu.Append(204, 'Print Pre&view', 'Preview the current plot')
     wx.EVT_MENU(self, 204, self.file_preview)
     menu.Append(205, 'Close\tCtrl-W', 'Close plot')
     wx.EVT_MENU(self, 205, self.file_close)
     self.mainmenu.Append(menu, '&File')
     menu = wx.Menu()
     menu.Append(self.TITLE_TEXT, '&Graph Title', 'Title for plot')
     wx.EVT_MENU(self, self.TITLE_TEXT, self.title)
     menu.Append(self.X_TEXT, '&X Title', 'Title for X axis')
     wx.EVT_MENU(self, self.X_TEXT, self.title)
     menu.Append(self.Y_TEXT, '&Y Title', 'Title for Y axis')
     wx.EVT_MENU(self, self.Y_TEXT, self.title)
     self.mainmenu.Append(menu, '&Titles')
     #menu = wx.Menu()
     #menu.Append(300, '&Profile', 'Check the hot spots in the program')
     #wx.EVT_MENU(self,300,self.OnProfile)
     #self.mainmenu.Append(menu, '&Utility')
     self.SetMenuBar(self.mainmenu)
     # A status bar to tell people what's happening
     self.CreateStatusBar(1)
     self.print_data = wx.PrintData()
     self.print_data.SetPaperId(wx.PAPER_LETTER)
     self.client = plot_canvas(self)
     if visible: self.Show(1)
     self.Raise()
     self.SetFocus()
Esempio n. 11
0
    def __init__(self, parent, mode=ed_glob.PRINT_NORMAL):
        """Initializes the Printer
        @param stc_callable: function to get current stc document
        @keyword mode: printer mode

        """
        object.__init__(self)

        # Attributes
        self.stc = None
        self.title = wx.EmptyString
        self.parent = parent
        self.print_mode = mode
        self.print_data = wx.PrintData()
Esempio n. 12
0
 def printing(self, text):
     data = wx.PrintDialogData(self.pdata)
     printer = wx.Printer(data)
     printout = TextDocPrintout(text, '', self.margins)
     useSetupDialog = True
     if not printer.Print(
             self.parent, printout,
             useSetupDialog) and printer.GetLastError() == wx.PRINTER_ERROR:
         return False
     else:
         data = printer.GetPrintDialogData()
         self.pdata = wx.PrintData(data.GetPrintData())
     printout.Destroy()
     return True
Esempio n. 13
0
    def OnDoPrint(self, event):
        pdd = wx.PrintDialogData(self.printData)
        pdd.SetToPage(2)
        printer = wx.Printer(pdd)
        printout = MyPrintout(self.canvas)

        if not printer.Print(self.frame, printout, True):
            wx.MessageBox(
                u"مشکل در چاپ شدن وجود دارد\nممکن است چاپگر فعلي درست تنظيم نشده؟",
                u"چاپ شدن", wx.OK)
        else:
            self.printData = wx.PrintData(
                printer.GetPrintDialogData().GetPrintData())
        printout.Destroy()
 def OnPrint(self, evt):
     data = wx.PrintDialogData(self.pdata)
     printer = wx.Printer(data)
     text = self.tc.GetValue()
     printout = TextDocPrintout(text, "title", self.margins)
     useSetupDialog = True
     if not printer.Print(self, printout, useSetupDialog) and printer.GetLastError() == wx.PRINTER_ERROR:
         wx.MessageBox(
         "There was a problem printing.\n"
         "Perhaps your current printer is not set correctly?","Printing Error", wx.OK)
     else:
         data = printer.GetPrintDialogData()
         self.pdata = wx.PrintData(data.GetPrintData()) # force a copy
         printout.Destroy()
Esempio n. 15
0
    def OnDoPrint(self, event):
        self.setup()
        pdd = wx.PrintDialogData(self.printData)
        # set number of pages/copies
        pdd.SetToPage(1)
        printer = wx.Printer(pdd)
        printout = MapPrint(self.mapwin)

        if not printer.Print(self.mapframe, printout, True):
            GMessage(_("There was a problem printing.\n"
                       "Perhaps your current printer is not set correctly?"))
        else:
            self.printData = wx.PrintData( printer.GetPrintDialogData().GetPrintData() )
        printout.Destroy()
Esempio n. 16
0
 def Print(self):
     pdd = wx.PrintDialogData(self.printData)
     printer = wx.Printer(pdd)
     printout = SetPrintout(self)
     if not printer.Print(self.parentFrame, printout):
         if wx.Printer.GetLastError() == wx.PRINTER_ERROR:
             wx.MessageBox(
                 "There was a problem printing.\n"
                 "Perhaps your current printer is not set correctly?",
                 "Printing", wx.OK)
     else:
         self.printData = wx.PrintData(
             printer.GetPrintDialogData().GetPrintData())
     printout.Destroy()
Esempio n. 17
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()
Esempio n. 18
0
    def __init__(self, parent, po, orientation=wx.PORTRAIT):
        self.m_parent = parent

        self.m_pd = wx.PrintData()
        if getLang() == 'us':
            self.m_pd.SetPaperId(wx.PAPER_LETTER)
        else:
            self.m_pd.SetPaperId(wx.PAPER_A4)

        self.m_pd.SetOrientation(orientation)

        self.m_pd.SetPrintMode(wx.PRINT_MODE_PRINTER)

        self.m_po = po
Esempio n. 19
0
 def showPrint(self):
     pdd = wx.PrintDialogData(self.getPrintData())
     printer = wx.Printer(pdd)
     printout = STCPrintout(self.stc)
     result = printer.Print(self.stc, printout)
     if result:
         data = printer.GetPrintDialogData()
         self.print_data = wx.PrintData(data.GetPrintData())
     elif printer.GetLastError() == wx.PRINTER_ERROR:
         wx.MessageBox(_("There was an error when printing.\n"
                         "Check that your printer is properly connected."),
                       _("Printer Error"),
                       style=wx.ICON_ERROR|wx.OK)
     printout.Destroy()
Esempio n. 20
0
 def PageSetup(self):
     data = wx.PageSetupDialogData()
     data.SetPrintData(self.printData)
     data.SetDefaultMinMargins(True)
     data.SetMarginTopLeft(self.margins[0])
     data.SetMarginBottomRight(self.margins[1])
     dlg = wx.PageSetupDialog(None, data)
     if dlg.ShowModal() == wx.ID_OK:
         data = dlg.GetPageSetupData()
         self.printData = wx.PrintData(data.GetPrintData())
         self.printData.SetPaperId(data.GetPaperId())
         self.margins = (data.GetMarginTopLeft(),
                         data.GetMarginBottomRight())
     dlg.Destroy()
Esempio n. 21
0
    def Print(self):
        """
        Prints the canvas.
        """
        printer = self.GetPrinter()
        fig = self.get_figure()

        # 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 (causing segfaults)
        printData = wx.PrintData(printer.getPrintData())
        self.printFigure(fig, "Plot")
        self.printer.setPrintData(printData)  # reset print data
        self.draw()
Esempio n. 22
0
        def __init__(self, parent, ID, title):
            # Specify the Internationalization Base
            gettext.install("ReportPrintoutClass")
            # Create the basic Frame structure with a white background
            self.frame = wx.Frame.__init__(self, parent, ID, 'Transana - %s' % title, pos=(10, 10), size=(300, 150), style=wx.DEFAULT_FRAME_STYLE | wx.TAB_TRAVERSAL | wx.NO_FULL_REPAINT_ON_RESIZE)
            self.title = title
            self.SetBackgroundColour(wx.WHITE)

            # Add a Menu Bar
            menuBar = wx.MenuBar()                                                        # Create the Menu Bar
            self.menuFile = wx.Menu()                                                     # Create the File Menu
            self.menuFile.Append(M_FILE_PRINTSETUP, "Printer Setup", "Set up Printer")      # Add "Printer Setup" to the File Menu
            self.menuFile.Append(M_FILE_PRINTPREVIEW, "Print Preview", "Preview your printed output") # Add "Print Preview" to the File Menu
            self.menuFile.Append(M_FILE_PRINT, "&Print", "Send your output to the Printer") # Add "Print" to the File Menu
            self.menuFile.Append(M_FILE_EXIT, "E&xit", "Exit the %s program" % self.title)  # Add "Exit" to the File Menu
            menuBar.Append(self.menuFile, '&File')                                          # Add the File Menu to the Menu Bar
            wx.EVT_MENU(self, M_FILE_PRINTSETUP, self.OnPrintSetup)                         # Attach File > Print Setup to a method
            wx.EVT_MENU(self, M_FILE_PRINTPREVIEW, self.OnPrintPreview)                     # Attach File > Print Preview to a method
            wx.EVT_MENU(self, M_FILE_PRINT, self.OnPrint)                                   # Attach File > Print to a method
            wx.EVT_MENU(self, M_FILE_EXIT, self.CloseWindow)                                # Attach CloseWindow to File > Exit
            self.SetMenuBar(menuBar)                                                        # Connect the Menu Bar to the Frame

            # Add a Status Bar
            self.CreateStatusBar()

            # Prepare the wxPrintData object for use in Printing
            self.printData = wx.PrintData()
            self.printData.SetPaperId(wx.PAPER_LETTER)

            # Show the Frame
            self.Show(True)

            # Get a filename of an RTF file to use as the transcript
            dlg = wx.FileDialog(None, wildcard="*.rtf", style=wx.OPEN)
            if dlg.ShowModal() == wx.ID_OK:
                fname = dlg.GetPath()
                dlg.Destroy()
            else:
                dlg.Destroy()
                self.Close()
            
            # Create a dummy Transcript object
            self.transcriptObj = Transcript.Transcript()
            f = open(fname, "r")
            self.transcriptObj.text = f.read()
            f.close()

            # Initialize the pageData structure to an empty list
            self.pageData = []
Esempio n. 23
0
    def Print(self):
        """Prints the document
        @postcondition: the current document is printed

        """
        pdd = wx.PrintDialogData()
        pdd.SetPrintData(self.print_data)
        printer = wx.Printer(pdd)
        printout = self.CreatePrintout()
        result = printer.Print(self.parent, printout)

        if result:
            dlg_data = printer.GetPrintDialogData()
            self.print_data = wx.PrintData(dlg_data.GetPrintData())
        printout.Destroy()
Esempio n. 24
0
    def Tricky(self):
        self.log = Log()
        self.frame = wx.Frame()
        self.notebook = wx.Notebook(self.frame, -1)
        self.umlwin = UmlCanvas(panel, Log(), self.frame)
        self.umlwin = UmlCanvas(panel, Log(), self.frame)
        self.umlwin = UmlCanvas(panel, Log(), self.frame)
        self.umlwin = UmlCanvas(panel, Log(), self.frame)
        self.umlwin = UmlCanvas(self.notebook, Log(), self.frame)
        self.umlwin = UmlCanvas(self.frame, Log(), self.frame)
        self.multiText = wx.TextCtrl
        self.app = App(context)
        self.user_config_file = os.path.join(config_dir, PYNSOURCE_CONFIG_FILE)
        self.config = ConfigObj(self.user_config_file)  # doco at
        self.popupmenu = wx.Menu()
        self.next_menu_id = wx.NewId(
        )  # ---- yike how to tell if LIBRARY call is class or function !!
        self.printData = wx.PrintData()
        self.printData = wx.PrintData()
        self.box = wx.BoxSizer(wx.VERTICAL)

        # trickier cases
        self.canvas = self.umlwin.GetDiagram().GetCanvas()
        self.curr.append(" " * self.curr_width)
Esempio n. 25
0
 def OnPrint(self, event):
     xml = self.GetXML()
     printout = wx.richtext.RichTextPrintout()  #wx.html.HtmlPrintout()
     printout.SetRichTextBuffer(self.ctrl_editeur.GetBuffer())
     data = wx.PrintDialogData()
     data.SetAllPages(True)
     data.SetCollate(True)  # Pour assembler les pages
     # définit les paramètres de l'impression
     datapr = wx.PrintData()
     data.SetPrintData(datapr)
     # Impression
     printer = wx.Printer(data)
     printer.Print(self, printout, True)
     # Pour éviter le bug des marges qui se rajoutent après l'aperçu
     self.SetXML(xml)
Esempio n. 26
0
    def __init__(self, parent, stc_callable, mode=ed_glob.PRINT_NORMAL):
        """Initializes the Printer, the stc_callable parameter
        must be a callable function that returns an STC instance object
        @param stc_callable: function to get current stc document
        @keyword mode: printer mode

        """
        object.__init__(self)

        # Attributes
        self.stc = stc_callable
        self.title = wx.EmptyString
        self.parent = parent
        self.print_mode = mode
        self.print_data = wx.PrintData()
Esempio n. 27
0
 def ImpressionRapide(self, nbreExemplaires=1):
     pd = wx.PrintData()
     pd.SetPrinterName('')
     pd.SetOrientation(self.GetParent().orientation)
     pd.SetPaperId(wx.PAPER_A4)
     pd.SetQuality(wx.PRINT_QUALITY_DRAFT)
     pd.SetColour(True)
     pd.SetNoCopies(nbreExemplaires)
     pd.SetCollate(True)
     
     pdd = wx.PrintDialogData()
     pdd.SetPrintData(pd)
     
     printer = wx.Printer(pdd)
     printer.Print(self.parent, self.preview.GetPrintoutForPrinting(), False)
Esempio n. 28
0
    def __init__(self, parent, mode=ed_glob.PRINT_NORMAL):
        """Initializes the Printer
        @param parent: parent window
        @keyword mode: printer mode

        """
        object.__init__(self)

        # Attributes
        self.stc = None
        self.title = wx.EmptyString
        self.parent = parent
        self.print_mode = mode
        self.print_data = wx.PrintData()
        self.margins = (wx.Point(15, 15), wx.Point(15, 15))
Esempio n. 29
0
    def test_PostscriptDC1(self):
        pd = wx.PrintData()
        pd.SetPrintMode(wx.PRINT_MODE_FILE)
        pd.SetFilename(fileName)

        dc = wx.PostScriptDC(pd)
        pen = wx.Pen('black')
        self.assertTrue(pen.IsOk())
        dc.StartDoc("message")
        dc.SetPen(pen)
        dc.DrawLine(0, 0, 50, 50)
        dc.EndDoc()
        del dc

        os.remove(fileName)
Esempio n. 30
0
 def Print(self, bmp):
     pdd = wx.PrintDialogData(self.print_data)
     printer = wx.Printer(pdd)
     printout = self.CreatePrintout(bmp)
     result = printer.Print(self.parent, printout)
     if result:
         # Store copy of print data for future use
         dlg_data = printer.GetPrintDialogData()
         newdata = dlg_data.GetPrintData()
         self.print_data = wx.PrintData(newdata)
     elif printer.GetLastError() == wx.PRINTER_ERROR:
         wx.MessageBox("Printer error detected.",
                       "Printer Error",
                       style=wx.ICON_ERROR | wx.OK)
     printout.Destroy()