Example #1
0
 def __init__(self, parent):
     wx.Panel.__init__(self, parent)
     #PDFWindow.__init__(self, style = wx.SUNKEN_BORDER)
     self.pdfwin = PDFWindow(self)
     sizer = wx.BoxSizer(wx.HORIZONTAL)
     sizer.Add(self.pdfwin, 1, wx.EXPAND)
     self.SetSizer(sizer)
Example #2
0
    def __init__(self, parent, log):
        wx.Panel.__init__(self, parent, -1)
        self.pdf = None

        sizer = wx.BoxSizer(wx.VERTICAL)
        btnSizer = wx.BoxSizer(wx.HORIZONTAL)

        self.pdf = PDFWindow(self, style=wx.SUNKEN_BORDER)

        sizer.Add(self.pdf, proportion=1, flag=wx.EXPAND)

        btn = wx.Button(self, wx.NewId(), "Open PDF File")
        self.Bind(wx.EVT_BUTTON, self.OnOpenButton, btn)
        btnSizer.Add(btn, proportion=1, flag=wx.EXPAND | wx.ALL, border=5)

        btn = wx.Button(self, wx.NewId(), "<-- Previous Page")
        self.Bind(wx.EVT_BUTTON, self.OnPrevPageButton, btn)
        btnSizer.Add(btn, proportion=1, flag=wx.EXPAND | wx.ALL, border=5)

        btn = wx.Button(self, wx.NewId(), "Next Page -->")
        self.Bind(wx.EVT_BUTTON, self.OnNextPageButton, btn)
        btnSizer.Add(btn, proportion=1, flag=wx.EXPAND | wx.ALL, border=5)

        btnSizer.Add((50, -1), proportion=2, flag=wx.EXPAND)
        sizer.Add(btnSizer, proportion=0, flag=wx.EXPAND)

        self.SetSizer(sizer)
        self.SetAutoLayout(True)
Example #3
0
    def __init__(self, parent, name, appUrl, venueUrl, connectionId):
        wx.Panel.__init__(self, parent, -1)

        reactor.interleave(wx.CallAfter)
        
        # Create ActiveX interface to adobe acrobate reader
        self.pdf = PDFWindow(self)
        
        # Do UI layout
        self.__Layout()
    
        # Create UI events
        EVT_BUTTON(self, self.openButton.GetId(), self.OnOpenButton)
        EVT_BUTTON(self, self.prevButton.GetId(), self.OnPrevPageButton)
        EVT_BUTTON(self, self.nextButton.GetId(), self.OnNextPageButton)
        EVT_WINDOW_DESTROY(self, self.OnExit)

        # Create shared application client        
        self.sharedAppClient = SharedAppClient(name)
        self.log = self.sharedAppClient.InitLogging()
        self.log.debug("PdfViewer.__init__: Start pdf viewer, venueUrl: %s, appUrl: %s"%(venueUrl, appUrl))

        # Get client profile
        clientProfile = ClientProfile(UserConfig.instance().GetProfile())
       
        # Join the application session.
        self.sharedAppClient.Join(appUrl, clientProfile)
        self.id = self.sharedAppClient.GetPublicId()
                
        # Register callbacks for external events
        self.sharedAppClient.RegisterEventCallback("openFile", self.OpenCallback)
        self.sharedAppClient.RegisterEventCallback("changePage", self.ChangePageCallback)

        # Create data store interface
        self.dataStoreClient = GetVenueDataStore(venueUrl, connectionId)

        self.file = None
        self.pageNr = 1
        
        # Get current state
        self.file = str(self.sharedAppClient.GetData("file"))
        self.pageNr = int(self.sharedAppClient.GetData("page"))
        if not self.pageNr:
            self.pageNr = 1

        if self.file:
            try:
                self.dataStoreClient.Download(self.file, "tmp")
                self.pdf.LoadFile("tmp")
                self.pdf.setCurrentPage( int(self.pageNr))
            except:
                self.log.exception("PdfViewer.__init__: Download failed %s"%(self.file))
Example #4
0
    def __init__(self, parent):

        wx.Panel.__init__(self, parent, id=-1)

        self.pdf = None
        sizer = wx.BoxSizer(wx.VERTICAL)

        if True:  #NOT_USE_ADOBE:
            if HAS_PDFVIEWER:
                self.pdf = pdfViewer(
                    self, -1, wx.DefaultPosition, wx.DefaultSize,
                    wx.HSCROLL | wx.VSCROLL | wx.SUNKEN_BORDER)
            else:
                self.pdf = PanelBoutonPdf(self)
        else:
            m = GetProtectedModeReader()
            EnableProtectedModeReader(0)
            self.pdf = PDFWindow(self, style=wx.SUNKEN_BORDER)
            EnableProtectedModeReader(m)

#        if ADOBE_VERSION == None:
#            self.pdf = wx.StaticText(self, -1, u"Cette fonctionnalité n'est disponible qu'avec Adobe Acrobat Reader\n"\
#                                                   u"Pour obtenir le dossier de validation, passer par le menu Fichier/Générer le dossier de validation.")
#        else:
#            if ADOBE_VERSION[:3] == (11, 0, 7) or ADOBE_VERSION[:3] == (11, 0, 8):
#                self.pdf = wx.StaticText(self, -1, u"Cette fonctionnalité n'est pas compatible Adobe Acrobat Reader version 11.0.07 !!\n\n"\
#                                                   u"Pour visualiser le dossier de validation :\n"\
#                                                   u" - Passer à la version 10.0.09 - si disponible (http://get.adobe.com/fr/reader)\n" \
#                                                   u" - Utiliser la version 11.0.06 (http://www.adobe.com/support/downloads/product.jsp?product=10&platform=Windows)\n" \
#                                                   u" - Utiliser la version 10 (http://get.adobe.com/fr/reader/otherversions)\n" \
#                                                   u" - Générer le fichier .pdf : menu Fichier/Générer le dossier de validation projet")
#            elif get_min_adobe_version() != None:
#                self.pdf = PDFWindow(self, style=wx.SUNKEN_BORDER)
#            else:
#                self.pdf = wx.StaticText(self, -1, u"Cette fonctionnalité n'est disponible qu'avec Adobe Acrobat Reader\n"\
#                                                   u"Pour obtenir le dossier de validation, passer par le menu Fichier/Générer le dossier de validation.")
#        else:
#            self.pdf = pdfViewer( self, -1, wx.DefaultPosition,
#                                wx.DefaultSize, wx.HSCROLL|wx.VSCROLL|wx.SUNKEN_BORDER)
        sizer.Add(self.pdf, proportion=1, flag=wx.EXPAND)

        self.mess = wx.StaticText(self, -1, "")
        sizer.Add(self.mess, proportion=1, flag=wx.EXPAND)
        sizer.Show(self.mess, False)

        self.SetSizer(sizer)
        self.sizer = sizer
        self.SetAutoLayout(True)

        self.pdf.Bind(wx.EVT_ENTER_WINDOW, self.OnEnter)

        FullScreenWin.__init__(self, self.pdf)
Example #5
0
class TestPanel(wx.Panel):
    def __init__(self, parent, log):
        wx.Panel.__init__(self, parent, -1)
        self.pdf = None

        sizer = wx.BoxSizer(wx.VERTICAL)
        btnSizer = wx.BoxSizer(wx.HORIZONTAL)

        self.pdf = PDFWindow(self, style=wx.SUNKEN_BORDER)

        sizer.Add(self.pdf, proportion=1, flag=wx.EXPAND)

        btn = wx.Button(self, wx.NewId(), "Open PDF File")
        self.Bind(wx.EVT_BUTTON, self.OnOpenButton, btn)
        btnSizer.Add(btn, proportion=1, flag=wx.EXPAND|wx.ALL, border=5)

        btn = wx.Button(self, wx.NewId(), "<-- Previous Page")
        self.Bind(wx.EVT_BUTTON, self.OnPrevPageButton, btn)
        btnSizer.Add(btn, proportion=1, flag=wx.EXPAND|wx.ALL, border=5)

        btn = wx.Button(self, wx.NewId(), "Next Page -->")
        self.Bind(wx.EVT_BUTTON, self.OnNextPageButton, btn)
        btnSizer.Add(btn, proportion=1, flag=wx.EXPAND|wx.ALL, border=5)


        btnSizer.Add((50,-1), proportion=2, flag=wx.EXPAND)
        sizer.Add(btnSizer, proportion=0, flag=wx.EXPAND)

        self.SetSizer(sizer)
        self.SetAutoLayout(True)



    def OnOpenButton(self, event):
        dlg = wx.FileDialog(self, wildcard="*.pdf")

        if dlg.ShowModal() == wx.ID_OK:
            wx.BeginBusyCursor()
            self.pdf.LoadFile(dlg.GetPath())
            wx.EndBusyCursor()

        dlg.Destroy()


    def OnPrevPageButton(self, event):
        self.pdf.gotoPreviousPage()


    def OnNextPageButton(self, event):
        self.pdf.gotoNextPage()
Example #6
0
    def __init__(self, parent, id=wx.ID_ANY):
        wx.Panel.__init__(self, parent, id)
        sizer = wx.BoxSizer(wx.HORIZONTAL)
        if _pdf_available:
            # create the pdf viewer
            self.pdf = PDFWindow(self, style=wx.SUNKEN_BORDER)
            sizer.Add(self.pdf, 1, flag=wx.EXPAND)

            # create the tmp dir and bind to the close event
            self.tmpdir = tempfile.mkdtemp()
            self.Bind(wx.EVT_CLOSE, self.OnClose)
        else:
            sizer.Add(wx.StaticText(self, -1, "PDF viewer not available"))

        self.SetSizer(sizer)
        self.Fit()
Example #7
0
    def __init__(self, parent, log):
        wx.Panel.__init__(self, parent, -1)
        self.pdf = None

        sizer = wx.BoxSizer(wx.VERTICAL)
        btnSizer = wx.BoxSizer(wx.HORIZONTAL)

        self.pdf = PDFWindow(self, style=wx.SUNKEN_BORDER)

        sizer.Add(self.pdf, proportion=1, flag=wx.EXPAND)

        btn = wx.Button(self, wx.NewId(), "Open PDF File")
        self.Bind(wx.EVT_BUTTON, self.OnOpenButton, btn)
        btnSizer.Add(btn, proportion=1, flag=wx.EXPAND|wx.ALL, border=5)

        btn = wx.Button(self, wx.NewId(), "<-- Previous Page")
        self.Bind(wx.EVT_BUTTON, self.OnPrevPageButton, btn)
        btnSizer.Add(btn, proportion=1, flag=wx.EXPAND|wx.ALL, border=5)

        btn = wx.Button(self, wx.NewId(), "Next Page -->")
        self.Bind(wx.EVT_BUTTON, self.OnNextPageButton, btn)
        btnSizer.Add(btn, proportion=1, flag=wx.EXPAND|wx.ALL, border=5)


        btnSizer.Add((50,-1), proportion=2, flag=wx.EXPAND)
        sizer.Add(btnSizer, proportion=0, flag=wx.EXPAND)

        self.SetSizer(sizer)
        self.SetAutoLayout(True)
Example #8
0
class TestPanel(wx.Panel):
    def __init__(self, parent, log):
        wx.Panel.__init__(self, parent, -1)
        self.pdf = None

        sizer = wx.BoxSizer(wx.VERTICAL)
        btnSizer = wx.BoxSizer(wx.HORIZONTAL)

        self.pdf = PDFWindow(self, style=wx.SUNKEN_BORDER)

        sizer.Add(self.pdf, proportion=1, flag=wx.EXPAND)

        btn = wx.Button(self, wx.NewId(), "Open PDF File")
        self.Bind(wx.EVT_BUTTON, self.OnOpenButton, btn)
        btnSizer.Add(btn, proportion=1, flag=wx.EXPAND | wx.ALL, border=5)

        btn = wx.Button(self, wx.NewId(), "<-- Previous Page")
        self.Bind(wx.EVT_BUTTON, self.OnPrevPageButton, btn)
        btnSizer.Add(btn, proportion=1, flag=wx.EXPAND | wx.ALL, border=5)

        btn = wx.Button(self, wx.NewId(), "Next Page -->")
        self.Bind(wx.EVT_BUTTON, self.OnNextPageButton, btn)
        btnSizer.Add(btn, proportion=1, flag=wx.EXPAND | wx.ALL, border=5)

        btnSizer.Add((50, -1), proportion=2, flag=wx.EXPAND)
        sizer.Add(btnSizer, proportion=0, flag=wx.EXPAND)

        self.SetSizer(sizer)
        self.SetAutoLayout(True)

    def OnOpenButton(self, event):
        dlg = wx.FileDialog(self, wildcard="*.pdf")

        if dlg.ShowModal() == wx.ID_OK:
            wx.BeginBusyCursor()
            self.pdf.LoadFile(dlg.GetPath())
            wx.EndBusyCursor()

        dlg.Destroy()

    def OnPrevPageButton(self, event):
        self.pdf.gotoPreviousPage()

    def OnNextPageButton(self, event):
        self.pdf.gotoNextPage()
Example #9
0
    def __init__(self, parent, path=None):
        """
        """
        wx.Panel.__init__(self, parent, id=-1)
        
        self.parent = parent
        self.path = path
        sizer = wx.BoxSizer(wx.VERTICAL)
        btnSizer = wx.BoxSizer(wx.HORIZONTAL)
        
        self.pdf = PDFWindow(self, style=wx.SUNKEN_BORDER)
        
        sizer.Add(self.pdf, proportion=1, flag=wx.EXPAND)
        
        btn = wx.Button(self, wx.NewId(), "Open PDF File")
        self.Bind(wx.EVT_BUTTON, self.OnOpenButton, btn)
        btnSizer.Add(btn, proportion=1, flag=wx.EXPAND|wx.ALL, border=5)

        self.pdf.LoadFile(self.path)
        btn = wx.Button(self, wx.NewId(), "Previous Page")
        self.Bind(wx.EVT_BUTTON, self.OnPrevPageButton, btn)
        btnSizer.Add(btn, proportion=1, flag=wx.EXPAND|wx.ALL, border=5)

        btn = wx.Button(self, wx.NewId(), "Next Page")
        self.Bind(wx.EVT_BUTTON, self.OnNextPageButton, btn)
        btnSizer.Add(btn, proportion=1, flag=wx.EXPAND|wx.ALL, border=5)
        
        btn = wx.Button(self, wx.NewId(), "Close")
        self.Bind(wx.EVT_BUTTON, self.OnClose, btn)
        btnSizer.Add(btn, proportion=1, flag=wx.EXPAND|wx.ALL, border=5)
        btnSizer.Add((50,-1), proportion=2, flag=wx.EXPAND)
        sizer.Add(btnSizer, proportion=0, flag=wx.EXPAND)

        self.SetSizer(sizer)
        self.SetAutoLayout(True)
        wx.EVT_CLOSE(self.parent, self.OnClose)
Example #10
0
    def DisplayPDF(self):

        panel = wx.Panel(self)
        
        panel_sizer = wx.BoxSizer(wx.VERTICAL)
        
        self.pdf = PDFWindow(panel, style=wx.SUNKEN_BORDER)
        
        panel_sizer.Add(self.pdf, proportion=1, flag=wx.EXPAND)

        
        panel.SetSizer(panel_sizer)
        panel.SetAutoLayout(True)

        self.pdf.LoadFile("Rhythms.pdf")

        #Delete the PDF and ly files once loaded as we don't need them anymore
        os.remove("Rhythms.pdf")
        os.remove("Rhythms.ly")


        self.SetSize((1280, 800))
        self.Centre()
        self.Show(True)
Example #11
0
class PDFWindowWin(wx.Panel):
    """Adobe based pdf viewer for windows"""
    def __init__(self, parent):
        wx.Panel.__init__(self, parent)
        #PDFWindow.__init__(self, style = wx.SUNKEN_BORDER)
        self.pdfwin = PDFWindow(self)
        sizer = wx.BoxSizer(wx.HORIZONTAL)
        sizer.Add(self.pdfwin, 1, wx.EXPAND)
        self.SetSizer(sizer)

    def goto_prevpage(self):
        self.gotoPreviousPage()

    def goto_nextpage(self):
        self.gotoNextPage()

    def load_file(self, file):
        self.pdfwin.LoadFile(file)
Example #12
0
class DAGViewer(wx.Panel):
    """
    Panel that calls ctx.to_dot for a particular node to
    render it to a .pdf and displays that using an embedded
    pdf ActiveX control.
    """
    def __init__(self, parent, id=wx.ID_ANY):
        wx.Panel.__init__(self, parent, id)
        sizer = wx.BoxSizer(wx.HORIZONTAL)
        if _pdf_available:
            # create the pdf viewer
            self.pdf = PDFWindow(self, style=wx.SUNKEN_BORDER)
            sizer.Add(self.pdf, 1, flag=wx.EXPAND)

            # create the tmp dir and bind to the close event
            self.tmpdir = tempfile.mkdtemp()
            self.Bind(wx.EVT_CLOSE, self.OnClose)
        else:
            sizer.Add(wx.StaticText(self, -1, "PDF viewer not available"))

        self.SetSizer(sizer)
        self.Fit()

    def OnClose(self, event):
        shutil.rmtree(self.tmpdir, ignore_errors=True)

    def SetNodes(self, nodes, ctx, max_depth, layout_style):
        if not _pdf_available:
            return

        filename = os.path.join(self.tmpdir, "dot.pdf")
        ctx.to_dot(filename,
                   nodes=nodes,
                   all_contexts=False,
                   max_depth=max_depth,
                   rankdir=layout_style)

        self.pdf.LoadFile(filename)
        self.GetSizer().Layout()
Example #13
0
class RhythmWindow(wx.Frame):

    #Initialise window and set icon
    def __init__(self, *args, **kw):
        super(RhythmWindow, self).__init__(None, title='Rhythms', style=wx.DEFAULT_FRAME_STYLE)

        ico = wx.Icon('files/icon.ico', wx.BITMAP_TYPE_ICO)
        self.SetIcon(ico)

        self.DisplayPDF()


    #Load the PDF file into the window
    def DisplayPDF(self):

        panel = wx.Panel(self)
        
        panel_sizer = wx.BoxSizer(wx.VERTICAL)
        
        self.pdf = PDFWindow(panel, style=wx.SUNKEN_BORDER)
        
        panel_sizer.Add(self.pdf, proportion=1, flag=wx.EXPAND)

        
        panel.SetSizer(panel_sizer)
        panel.SetAutoLayout(True)

        self.pdf.LoadFile("Rhythms.pdf")

        #Delete the PDF and ly files once loaded as we don't need them anymore
        os.remove("Rhythms.pdf")
        os.remove("Rhythms.ly")


        self.SetSize((1280, 800))
        self.Centre()
        self.Show(True)
Example #14
0
    def __init__(self, parent, log):
        wx.Panel.__init__(self, parent, -1)

        mainsizer = wx.BoxSizer(wx.HORIZONTAL)
        leftsizer = wx.BoxSizer(wx.VERTICAL)
        self.pdf = PDFWindow(self, style=wx.SUNKEN_BORDER)
        leftsizer.Add(self.pdf, proportion=1, flag=wx.EXPAND)

        box = wx.StaticBox(self, wx.NewId(), "" )
        buttonsizer = wx.StaticBoxSizer(box, wx.HORIZONTAL )
    
        b1 = wx.Button(self, wx.NewId(), "First")
        buttonsizer.Add(b1, proportion=0, flag=wx.ALIGN_CENTER|wx.ALL, border=5)
        self.Bind(wx.EVT_BUTTON, self.OnFirstPageButton, b1)

        b2 = wx.Button(self,  wx.NewId(), "Previous")
        buttonsizer.Add(b2, proportion=0, flag=wx.ALIGN_CENTER|wx.ALL, border=5)
        self.Bind(wx.EVT_BUTTON, self.OnPreviousPageButton, b2)
        
        tx1 = wx.StaticText(self, wx.NewId(), "   Go to page" )
        buttonsizer.Add(tx1, proportion=0, flag=wx.ALIGN_CENTER|wx.ALL, border=5)
        tc1 = wx.TextCtrl(self, wx.NewId(), "0", size=[30,-1])
        buttonsizer.Add( tc1, proportion=0, flag=wx.ALIGN_CENTER|wx.ALL, border=5)
        self.Bind(wx.EVT_TEXT, self.OnGotoPage, tc1)
    
        b3 = wx.Button(self, wx.NewId(), "Next")
        buttonsizer.Add(b3, proportion=0, flag=wx.ALIGN_CENTER|wx.ALL, border=5)
        self.Bind(wx.EVT_BUTTON, self.OnNextPageButton, b3)

        b4 = wx.Button(self, wx.NewId(), "Last")
        buttonsizer.Add(b4, proportion=0, flag=wx.ALIGN_CENTER|wx.ALL, border=5)
        self.Bind(wx.EVT_BUTTON, self.OnLastPageButton, b4)

        tx2 = wx.StaticText(self, wx.NewId(), "     Zoom")
        buttonsizer.Add(tx2, proportion=0, flag=wx.ALIGN_CENTER|wx.ALL, border=5)
 
        ch1 = wx.Choice(self, wx.NewId(),
                        choices=["Default", "Fit", "FitH", "FitV",
                                 "25%", "50%", "75%", "100%", "125%", "200%", "400%"])
        ch1.SetSelection(0)
        buttonsizer.Add(ch1, proportion=0, flag=wx.ALIGN_CENTER|wx.ALL, border=5)
        self.Bind(wx.EVT_CHOICE, self.OnZoom, ch1)

        leftsizer.Add(buttonsizer, proportion=0)
        mainsizer.Add(leftsizer, proportion=1, flag=wx.GROW|wx.ALIGN_CENTER_HORIZONTAL|wx.ALL, border=5)

        box = wx.StaticBox(self, wx.NewId(), "" )
        rightsizer = wx.StaticBoxSizer(box, wx.VERTICAL)
    
        b5 = wx.Button(self, wx.NewId(), "Load PDF")
        rightsizer.Add(b5, proportion=0, flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL, border=5)
        self.Bind(wx.EVT_BUTTON, self.OnLoadButton, b5)

        b6 = wx.Button(self, wx.NewId(), "Print")
        rightsizer.Add(b6, proportion=0, flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL, border=5)
        self.Bind(wx.EVT_BUTTON, self.OnPrintButton, b6)

        tx3 = wx.StaticText(self, wx.NewId(), "Page mode:")
        rightsizer.Add(tx3, proportion=0, flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL, border=5)

        ch2 = wx.Choice(self, wx.NewId(),size=[100,-1],
                        choices=["None", "Bookmarks", "Thumbs"])
        ch2.SetSelection(0)
        rightsizer.Add(ch2, proportion=0, flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL, border=5)
        self.Bind(wx.EVT_CHOICE, self.OnPageMode, ch2)

        tx4 = wx.StaticText(self, wx.NewId(), "Layout mode:")
        rightsizer.Add(tx4, proportion=0, flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL, border=5)

        ch3 = wx.Choice(self, wx.NewId(),size=[100,-1],
                        choices=["DontCare", "SinglePage",
                                 "OneColumn", "TwoColumnLeft", "TwoColumnRight" ])
        ch3.SetSelection(0)
        rightsizer.Add(ch3, proportion=0, flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL, border=5)
        self.Bind(wx.EVT_CHOICE, self.OnLayoutMode, ch3)

        cx1 = wx.CheckBox(self, wx.NewId(), "Toolbar")
        cx1.SetValue( True )
        rightsizer.Add( cx1,proportion=0, flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL, border=5)
        self.Bind(wx.EVT_CHECKBOX, self.OnToolbar, cx1)

        cx2 = wx.CheckBox(self, wx.NewId(), "Scrollbars")
        cx2.SetValue( True )
        rightsizer.Add( cx2,proportion=0, flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL, border=5)
        self.Bind(wx.EVT_CHECKBOX, self.OnScrollbars, cx2)

        mainsizer.Add( rightsizer, proportion=0, flag=wx.ALL, border=15)
        self.SetSizer(mainsizer)
        self.SetAutoLayout(True)
Example #15
0
class TestPanel(wx.Panel):
    def __init__(self, parent, log):
        wx.Panel.__init__(self, parent, -1)

        mainsizer = wx.BoxSizer(wx.HORIZONTAL)
        leftsizer = wx.BoxSizer(wx.VERTICAL)
        self.pdf = PDFWindow(self, style=wx.SUNKEN_BORDER)
        leftsizer.Add(self.pdf, proportion=1, flag=wx.EXPAND)

        box = wx.StaticBox(self, wx.NewId(), "" )
        buttonsizer = wx.StaticBoxSizer(box, wx.HORIZONTAL )
    
        b1 = wx.Button(self, wx.NewId(), "First")
        buttonsizer.Add(b1, proportion=0, flag=wx.ALIGN_CENTER|wx.ALL, border=5)
        self.Bind(wx.EVT_BUTTON, self.OnFirstPageButton, b1)

        b2 = wx.Button(self,  wx.NewId(), "Previous")
        buttonsizer.Add(b2, proportion=0, flag=wx.ALIGN_CENTER|wx.ALL, border=5)
        self.Bind(wx.EVT_BUTTON, self.OnPreviousPageButton, b2)
        
        tx1 = wx.StaticText(self, wx.NewId(), "   Go to page" )
        buttonsizer.Add(tx1, proportion=0, flag=wx.ALIGN_CENTER|wx.ALL, border=5)
        tc1 = wx.TextCtrl(self, wx.NewId(), "0", size=[30,-1])
        buttonsizer.Add( tc1, proportion=0, flag=wx.ALIGN_CENTER|wx.ALL, border=5)
        self.Bind(wx.EVT_TEXT, self.OnGotoPage, tc1)
    
        b3 = wx.Button(self, wx.NewId(), "Next")
        buttonsizer.Add(b3, proportion=0, flag=wx.ALIGN_CENTER|wx.ALL, border=5)
        self.Bind(wx.EVT_BUTTON, self.OnNextPageButton, b3)

        b4 = wx.Button(self, wx.NewId(), "Last")
        buttonsizer.Add(b4, proportion=0, flag=wx.ALIGN_CENTER|wx.ALL, border=5)
        self.Bind(wx.EVT_BUTTON, self.OnLastPageButton, b4)

        tx2 = wx.StaticText(self, wx.NewId(), "     Zoom")
        buttonsizer.Add(tx2, proportion=0, flag=wx.ALIGN_CENTER|wx.ALL, border=5)
 
        ch1 = wx.Choice(self, wx.NewId(),
                        choices=["Default", "Fit", "FitH", "FitV",
                                 "25%", "50%", "75%", "100%", "125%", "200%", "400%"])
        ch1.SetSelection(0)
        buttonsizer.Add(ch1, proportion=0, flag=wx.ALIGN_CENTER|wx.ALL, border=5)
        self.Bind(wx.EVT_CHOICE, self.OnZoom, ch1)

        leftsizer.Add(buttonsizer, proportion=0)
        mainsizer.Add(leftsizer, proportion=1, flag=wx.GROW|wx.ALIGN_CENTER_HORIZONTAL|wx.ALL, border=5)

        box = wx.StaticBox(self, wx.NewId(), "" )
        rightsizer = wx.StaticBoxSizer(box, wx.VERTICAL)
    
        b5 = wx.Button(self, wx.NewId(), "Load PDF")
        rightsizer.Add(b5, proportion=0, flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL, border=5)
        self.Bind(wx.EVT_BUTTON, self.OnLoadButton, b5)

        b6 = wx.Button(self, wx.NewId(), "Print")
        rightsizer.Add(b6, proportion=0, flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL, border=5)
        self.Bind(wx.EVT_BUTTON, self.OnPrintButton, b6)

        tx3 = wx.StaticText(self, wx.NewId(), "Page mode:")
        rightsizer.Add(tx3, proportion=0, flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL, border=5)

        ch2 = wx.Choice(self, wx.NewId(),size=[100,-1],
                        choices=["None", "Bookmarks", "Thumbs"])
        ch2.SetSelection(0)
        rightsizer.Add(ch2, proportion=0, flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL, border=5)
        self.Bind(wx.EVT_CHOICE, self.OnPageMode, ch2)

        tx4 = wx.StaticText(self, wx.NewId(), "Layout mode:")
        rightsizer.Add(tx4, proportion=0, flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL, border=5)

        ch3 = wx.Choice(self, wx.NewId(),size=[100,-1],
                        choices=["DontCare", "SinglePage",
                                 "OneColumn", "TwoColumnLeft", "TwoColumnRight" ])
        ch3.SetSelection(0)
        rightsizer.Add(ch3, proportion=0, flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL, border=5)
        self.Bind(wx.EVT_CHOICE, self.OnLayoutMode, ch3)

        cx1 = wx.CheckBox(self, wx.NewId(), "Toolbar")
        cx1.SetValue( True )
        rightsizer.Add( cx1,proportion=0, flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL, border=5)
        self.Bind(wx.EVT_CHECKBOX, self.OnToolbar, cx1)

        cx2 = wx.CheckBox(self, wx.NewId(), "Scrollbars")
        cx2.SetValue( True )
        rightsizer.Add( cx2,proportion=0, flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL, border=5)
        self.Bind(wx.EVT_CHECKBOX, self.OnScrollbars, cx2)

        mainsizer.Add( rightsizer, proportion=0, flag=wx.ALL, border=15)
        self.SetSizer(mainsizer)
        self.SetAutoLayout(True)

    def OnFirstPageButton(self, event):
        self.pdf.gotoFirstPage()

    def OnPreviousPageButton(self, event):
        self.pdf.gotoPreviousPage()

    def OnNextPageButton(self, event):
        self.pdf.gotoNextPage()

    def OnLastPageButton(self, event):
        self.pdf.gotoLastPage()

    def OnGotoPage(self, event):
        npage = event.GetEventObject().GetValue()
        try:
            self.pdf.setCurrentPage(int(npage))
        except ValueError:
            pass

    def OnZoom(self, event):
        astring = event.GetEventObject().GetStringSelection()
        if astring.startswith('Fit'):
            self.pdf.setView(astring)
        else:
            try:
                percent = float(astring.replace('%',''))
                self.pdf.setZoom(percent)
            except ValueError:
                pass
        
    def OnLoadButton(self, event):
        dlg = wx.FileDialog(self, wildcard="*.pdf")
        if dlg.ShowModal() == wx.ID_OK:
            wx.BeginBusyCursor()
            self.pdf.LoadFile(dlg.GetPath())
            wx.EndBusyCursor()
        dlg.Destroy()

    def OnPrintButton(self, event):
        self.pdf.Print()

    def OnPageMode(self, event):
        astring = event.GetEventObject().GetStringSelection()
        self.pdf.setPageMode(astring.lower())

    def OnLayoutMode(self, event):
        astring = event.GetEventObject().GetStringSelection()
        self.pdf.setLayoutMode(astring)

    def OnToolbar(self, event):
        on = event.GetEventObject().GetValue()
        self.pdf.setShowToolbar(on)

    def OnScrollbars(self, event):
        on = event.GetEventObject().GetValue()
        self.pdf.setShowScrollbars(on)
Example #16
0
    def __init__(self, parent, log):
        wx.Panel.__init__(self, parent, -1)

        mainsizer = wx.BoxSizer(wx.HORIZONTAL)
        leftsizer = wx.BoxSizer(wx.VERTICAL)
        self.pdf = PDFWindow(self, style=wx.SUNKEN_BORDER)
        leftsizer.Add(self.pdf, proportion=1, flag=wx.EXPAND)

        box = wx.StaticBox(self, wx.NewId(), "" )
        buttonsizer = wx.StaticBoxSizer(box, wx.HORIZONTAL )
    
        b1 = wx.Button(self, wx.NewId(), "First")
        buttonsizer.Add(b1, proportion=0, flag=wx.ALIGN_CENTER|wx.ALL, border=5)
        self.Bind(wx.EVT_BUTTON, self.OnFirstPageButton, b1)

        b2 = wx.Button(self,  wx.NewId(), "Previous")
        buttonsizer.Add(b2, proportion=0, flag=wx.ALIGN_CENTER|wx.ALL, border=5)
        self.Bind(wx.EVT_BUTTON, self.OnPreviousPageButton, b2)
        
        tx1 = wx.StaticText(self, wx.NewId(), "   Go to page" )
        buttonsizer.Add(tx1, proportion=0, flag=wx.ALIGN_CENTER|wx.ALL, border=5)
        tc1 = wx.TextCtrl(self, wx.NewId(), "0", size=[30,-1])
        buttonsizer.Add( tc1, proportion=0, flag=wx.ALIGN_CENTER|wx.ALL, border=5)
        self.Bind(wx.EVT_TEXT, self.OnGotoPage, tc1)
    
        b3 = wx.Button(self, wx.NewId(), "Next")
        buttonsizer.Add(b3, proportion=0, flag=wx.ALIGN_CENTER|wx.ALL, border=5)
        self.Bind(wx.EVT_BUTTON, self.OnNextPageButton, b3)

        b4 = wx.Button(self, wx.NewId(), "Last")
        buttonsizer.Add(b4, proportion=0, flag=wx.ALIGN_CENTER|wx.ALL, border=5)
        self.Bind(wx.EVT_BUTTON, self.OnLastPageButton, b4)

        tx2 = wx.StaticText(self, wx.NewId(), "     Zoom")
        buttonsizer.Add(tx2, proportion=0, flag=wx.ALIGN_CENTER|wx.ALL, border=5)
 
        ch1 = wx.Choice(self, wx.NewId(),
                        choices=["Default", "Fit", "FitH", "FitV",
                                 "25%", "50%", "75%", "100%", "125%", "200%", "400%"])
        ch1.SetSelection(0)
        buttonsizer.Add(ch1, proportion=0, flag=wx.ALIGN_CENTER|wx.ALL, border=5)
        self.Bind(wx.EVT_CHOICE, self.OnZoom, ch1)

        leftsizer.Add(buttonsizer, proportion=0)
        mainsizer.Add(leftsizer, proportion=1, flag=wx.GROW|wx.ALIGN_CENTER_HORIZONTAL|wx.ALL, border=5)

        box = wx.StaticBox(self, wx.NewId(), "" )
        rightsizer = wx.StaticBoxSizer(box, wx.VERTICAL)
    
        b5 = wx.Button(self, wx.NewId(), "Load PDF")
        rightsizer.Add(b5, proportion=0, flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL, border=5)
        self.Bind(wx.EVT_BUTTON, self.OnLoadButton, b5)

        b6 = wx.Button(self, wx.NewId(), "Print")
        rightsizer.Add(b6, proportion=0, flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL, border=5)
        self.Bind(wx.EVT_BUTTON, self.OnPrintButton, b6)

        tx3 = wx.StaticText(self, wx.NewId(), "Page mode:")
        rightsizer.Add(tx3, proportion=0, flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL, border=5)

        ch2 = wx.Choice(self, wx.NewId(),size=[100,-1],
                        choices=["None", "Bookmarks", "Thumbs"])
        ch2.SetSelection(0)
        rightsizer.Add(ch2, proportion=0, flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL, border=5)
        self.Bind(wx.EVT_CHOICE, self.OnPageMode, ch2)

        tx4 = wx.StaticText(self, wx.NewId(), "Layout mode:")
        rightsizer.Add(tx4, proportion=0, flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL, border=5)

        ch3 = wx.Choice(self, wx.NewId(),size=[100,-1],
                        choices=["DontCare", "SinglePage",
                                 "OneColumn", "TwoColumnLeft", "TwoColumnRight" ])
        ch3.SetSelection(0)
        rightsizer.Add(ch3, proportion=0, flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL, border=5)
        self.Bind(wx.EVT_CHOICE, self.OnLayoutMode, ch3)

        cx1 = wx.CheckBox(self, wx.NewId(), "Toolbar")
        cx1.SetValue( True )
        rightsizer.Add( cx1,proportion=0, flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL, border=5)
        self.Bind(wx.EVT_CHECKBOX, self.OnToolbar, cx1)

        cx2 = wx.CheckBox(self, wx.NewId(), "Scrollbars")
        cx2.SetValue( True )
        rightsizer.Add( cx2,proportion=0, flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL, border=5)
        self.Bind(wx.EVT_CHECKBOX, self.OnScrollbars, cx2)

        mainsizer.Add( rightsizer, proportion=0, flag=wx.ALL, border=15)
        self.SetSizer(mainsizer)
        self.SetAutoLayout(True)
	def __init__(self, *args, **kwargs):
		PDFWindow.__init__(self, *args, **kwargs)
		TempFileMixIn.__init__(self, self._openFile, self._closeFile, checkFile=self.checkPdfFile, openBusyFile=self._openBusyFile)
		self.__path = os.path.join(paths.data, 'share', 'gnue', 'pdf')
Example #18
0
class PdfPanel(wx.Panel, FullScreenWin):
    def __init__(self, parent):

        wx.Panel.__init__(self, parent, id=-1)

        self.pdf = None
        sizer = wx.BoxSizer(wx.VERTICAL)

        if True:  #NOT_USE_ADOBE:
            if HAS_PDFVIEWER:
                self.pdf = pdfViewer(
                    self, -1, wx.DefaultPosition, wx.DefaultSize,
                    wx.HSCROLL | wx.VSCROLL | wx.SUNKEN_BORDER)
            else:
                self.pdf = PanelBoutonPdf(self)
        else:
            m = GetProtectedModeReader()
            EnableProtectedModeReader(0)
            self.pdf = PDFWindow(self, style=wx.SUNKEN_BORDER)
            EnableProtectedModeReader(m)

#        if ADOBE_VERSION == None:
#            self.pdf = wx.StaticText(self, -1, u"Cette fonctionnalité n'est disponible qu'avec Adobe Acrobat Reader\n"\
#                                                   u"Pour obtenir le dossier de validation, passer par le menu Fichier/Générer le dossier de validation.")
#        else:
#            if ADOBE_VERSION[:3] == (11, 0, 7) or ADOBE_VERSION[:3] == (11, 0, 8):
#                self.pdf = wx.StaticText(self, -1, u"Cette fonctionnalité n'est pas compatible Adobe Acrobat Reader version 11.0.07 !!\n\n"\
#                                                   u"Pour visualiser le dossier de validation :\n"\
#                                                   u" - Passer à la version 10.0.09 - si disponible (http://get.adobe.com/fr/reader)\n" \
#                                                   u" - Utiliser la version 11.0.06 (http://www.adobe.com/support/downloads/product.jsp?product=10&platform=Windows)\n" \
#                                                   u" - Utiliser la version 10 (http://get.adobe.com/fr/reader/otherversions)\n" \
#                                                   u" - Générer le fichier .pdf : menu Fichier/Générer le dossier de validation projet")
#            elif get_min_adobe_version() != None:
#                self.pdf = PDFWindow(self, style=wx.SUNKEN_BORDER)
#            else:
#                self.pdf = wx.StaticText(self, -1, u"Cette fonctionnalité n'est disponible qu'avec Adobe Acrobat Reader\n"\
#                                                   u"Pour obtenir le dossier de validation, passer par le menu Fichier/Générer le dossier de validation.")
#        else:
#            self.pdf = pdfViewer( self, -1, wx.DefaultPosition,
#                                wx.DefaultSize, wx.HSCROLL|wx.VSCROLL|wx.SUNKEN_BORDER)
        sizer.Add(self.pdf, proportion=1, flag=wx.EXPAND)

        self.mess = wx.StaticText(self, -1, "")
        sizer.Add(self.mess, proportion=1, flag=wx.EXPAND)
        sizer.Show(self.mess, False)

        self.SetSizer(sizer)
        self.sizer = sizer
        self.SetAutoLayout(True)

        self.pdf.Bind(wx.EVT_ENTER_WINDOW, self.OnEnter)

        FullScreenWin.__init__(self, self.pdf)

#         self.Bind(wx.EVT_CLOSE, self.OnClose )
#         self.pdf.Bind(wx.EVT_WINDOW_DESTROY, self.OnClose)
#         self.Bind(wx.EVT_WINDOW_DESTROY, self.OnDestroyWindow)

#     ######################################################################################################
#     def OnDestroyWindow(self, event):
#         print "OnDestroy pdf"
#         self.pdf.Unbind(wx.EVT_ENTER_WINDOW)
#         self.pdf.FreeDlls()
#         print "...FAIT"
#
######################################################################################################

    def PreClose(self):
        print("PreClose pdf")
        try:
            self.pdf.LoadFile(None)
            self.pdf.FreeDlls()
        except:
            pass

#
# #         self.sizer.Detach(self.pdf)
# #         self.pdf.Unbind(wx.EVT_ENTER_WINDOW)
#
#
#         self.pdf.Close()
# #         self.sizer.Remove(self.pdf)
# #         self.pdf.Destroy()
# #         time.sleep(3)
# #         wx.CallAfter(self.pdf.Close)
# #         self.Destroy()
# #         self.pdf.Destroy()
# #         evt.Skip()

######################################################################################################

    def OnEnter(self, event):
        #         print "OnEnter PDF"
        self.pdf.SetFocus()
        event.Skip()

    ######################################################################################################
    def MiseAJour(self, projet, fenDoc):
        """ Génération d'un fichier PDF temporaire pour affichage
              - Dossier de validation
              - ...
        """
        self.dosstemp = tempfile.mkdtemp()
        fichertemp = os.path.join(self.dosstemp, "pdfdoss.pdf")

        wx.BeginBusyCursor()
        Err = genererDossierValidation(fichertemp, projet, fenDoc)
        wx.EndBusyCursor()
        #         print("1")
        if len(Err) == 0:
            Err = self.chargerFichierPDF(fichertemp)


#         print("2")
#         self.sizer.Show(self.pdf, len(Err) == 0)
        self.sizer.Show(self.mess, len(Err) > 0)
        #         print("3")
        if len(Err) > 0:
            m = "Une erreur s'est porduite lors de la création ou l'affichage du fichier PDF.\n\n"
            m += "\n".join(Err)
            self.mess.SetLabel(m)

            self.sizer.Layout()

    ######################################################################################################
    def supprimerDossierTemp(self):
        """ Suppression  du dossier temporaire
             Méthode brute
        """
        if True:  #get_min_adobe_version() != None:
            try:
                shutil.rmtree(self.dosstemp)
            except:
                time.sleep(.5)
                try:
                    shutil.rmtree(self.dosstemp)
                except:
                    pass

    ######################################################################################################
    def chargerFichierPDF(self, nomFichier):
        """ Affichage en interne du fichier PDF
             ou bien mise à jour du bouton d'affichage externe
        """
        Err = []

        if isinstance(self.pdf, PanelBoutonPdf):
            self.pdf.MiseAJour(nomFichier)

        elif isinstance(self.pdf, pdfViewer):
            wx.BeginBusyCursor()
            try:
                self.pdf.LoadFile(nomFichier)
            except:
                Err.append("ERREUR pdfViewer")
            finally:
                wx.EndBusyCursor()

        elif isinstance(self.pdf, PDFWindow):
            wx.BeginBusyCursor()
            try:
                self.pdf.LoadFile(nomFichier)
            except:
                Err.append("ERREUR PDFWindow")
            finally:
                wx.EndBusyCursor()

        return Err
Example #19
0
class PdfViewer(wx.Panel):
    '''
    Shared application that uses the ActiveX interface to
    Adobe Acrobate Reader version 4 and higher. This
    application only works on Windows platforms. It uses
    the defined pdf activex class provided by wxPython.
    '''
    
    def __init__(self, parent, name, appUrl, venueUrl, connectionId):
        wx.Panel.__init__(self, parent, -1)

        reactor.interleave(wx.CallAfter)
        
        # Create ActiveX interface to adobe acrobate reader
        self.pdf = PDFWindow(self)
        
        # Do UI layout
        self.__Layout()
    
        # Create UI events
        EVT_BUTTON(self, self.openButton.GetId(), self.OnOpenButton)
        EVT_BUTTON(self, self.prevButton.GetId(), self.OnPrevPageButton)
        EVT_BUTTON(self, self.nextButton.GetId(), self.OnNextPageButton)
        EVT_WINDOW_DESTROY(self, self.OnExit)

        # Create shared application client        
        self.sharedAppClient = SharedAppClient(name)
        self.log = self.sharedAppClient.InitLogging()
        self.log.debug("PdfViewer.__init__: Start pdf viewer, venueUrl: %s, appUrl: %s"%(venueUrl, appUrl))

        # Get client profile
        clientProfile = ClientProfile(UserConfig.instance().GetProfile())
       
        # Join the application session.
        self.sharedAppClient.Join(appUrl, clientProfile)
        self.id = self.sharedAppClient.GetPublicId()
                
        # Register callbacks for external events
        self.sharedAppClient.RegisterEventCallback("openFile", self.OpenCallback)
        self.sharedAppClient.RegisterEventCallback("changePage", self.ChangePageCallback)

        # Create data store interface
        self.dataStoreClient = GetVenueDataStore(venueUrl, connectionId)

        self.file = None
        self.pageNr = 1
        
        # Get current state
        self.file = str(self.sharedAppClient.GetData("file"))
        self.pageNr = int(self.sharedAppClient.GetData("page"))
        if not self.pageNr:
            self.pageNr = 1

        if self.file:
            try:
                self.dataStoreClient.Download(self.file, "tmp")
                self.pdf.LoadFile("tmp")
                self.pdf.setCurrentPage( int(self.pageNr))
            except:
                self.log.exception("PdfViewer.__init__: Download failed %s"%(self.file))

    #
    # Callbacks for local UI events.
    #

    def OnOpenButton(self, event):
        '''
        Invoked when user clicks the open button.
        '''
        dlg = FileSelectorDialog(self, -1, "Select File Location", self.dataStoreClient)

        if dlg.ShowModal() == wx.ID_OK:
            selectedFile = dlg.GetFile()
            if selectedFile:
                wx.BeginBusyCursor()

                # Get file from venue
                try:
                    self.dataStoreClient.Download(selectedFile, "tmp")
                    self.pdf.LoadFile("tmp")
                    self.pdf.setCurrentPage(1)
                    self.pageNr = 1
                    self.file = selectedFile

                except:
                    self.log.exception("PdfViewer.OnOpenButton: Failed to download %s"%(selectedFile))
                    dlg = wx.MessageDialog(self, 'Failed to download %s.'%(selectedFile),
                                          'Download Failed', wx.OK | wx.ICON_ERROR)
                    dlg.ShowModal()
                    dlg.Destroy()

                else:
                    # Update shared app status
                    self.sharedAppClient.SetData("file", self.file)
                    self.sharedAppClient.SetData("page", self.pageNr)
                    
                    # Send event
                    self.sharedAppClient.SendEvent("openFile", self.file)
                    self.sharedAppClient.SendEvent("changePage",  str(self.pageNr))
                                       
                wx.EndBusyCursor()
          
    def OnPrevPageButton(self, event):
        '''
        Invoked when user clicks the previous button.
        '''
        self.pageNr = self.pageNr - 1
        self.pdf.setCurrentPage(self.pageNr)
        self.sharedAppClient.SendEvent("changePage", str(self.pageNr))
        self.sharedAppClient.SetData("page", self.pageNr)

    def OnNextPageButton(self, event):
        '''
        Invoked when user clicks the next button.
        '''
        self.pageNr = self.pageNr + 1
        self.pdf.setCurrentPage(self.pageNr)
        self.sharedAppClient.SendEvent("changePage", str(self.pageNr))
        self.sharedAppClient.SetData("page", self.pageNr)

    def OnExit(self, event):
        '''
        Shut down shared pdf.
        '''
        self.sharedAppClient.Shutdown()
        
    #    
    # Callbacks for external events
    #

    def OpenCallback(self, event):
        '''
        Invoked when a open event is received.
        '''
        self.file = str(event.GetData())
        id = event.GetSenderId()
        
        # Ignore my own events
        if self.id != id:
	    try:
                self.dataStoreClient.Download(self.file, "tmp")
            except:
                self.log.exception("PdfViewer.__OpenCallback: Download failed %s"%(self.file))
    	
	    wx.BeginBusyCursor()
            wx.CallAfter(self.pdf.LoadFile, "tmp")
            #wx.CallAfter(self.pdf.setCurrentPage, self.pageNr)
            wx.CallAfter(self.Refresh)
            wx.EndBusyCursor()
	              
    def ChangePageCallback(self, event):
        '''
        Invoked when a changePage event is received.
        '''
       
        id = event.GetSenderId()
        # Ignore my own events
        if self.id != id:
            self.pageNr = int(event.GetData())
            wx.CallAfter(self.pdf.setCurrentPage, int(self.pageNr))        
            wx.CallAfter(self.Refresh)
               
    def __Layout(self):
        '''
        Layout of ui components.
        '''

        # Create UI objects
        self.openButton = wx.Button(self, wx.NewId(), "Open PDF File")
        self.prevButton = wx.Button(self, wx.NewId(), "<-- Previous Page")
        self.nextButton = wx.Button(self, wx.NewId(), "Next Page -->")
        
        sizer = wx.BoxSizer(wx.VERTICAL)
        btnSizer = wx.BoxSizer(wx.HORIZONTAL)
        
        sizer.Add(self.pdf, proportion=1, flag=wx.EXPAND)

        btnSizer.Add(self.openButton, proportion=1, flag=wx.EXPAND|wx.ALL, border=5)
        btnSizer.Add(self.prevButton, proportion=1, flag=wx.EXPAND|wx.ALL, border=5)
        btnSizer.Add(self.nextButton, proportion=1, flag=wx.EXPAND|wx.ALL, border=5)

        btnSizer.Add((50,-1), proportion=2, flag=wx.EXPAND)
        sizer.Add(btnSizer, proportion=0, flag=wx.EXPAND)

        self.SetSizer(sizer)
        self.SetAutoLayout(True)
Example #20
0
class PDFPanel(wx.Panel):
    """
    Panel that contains the pdf reader
    """
    def __init__(self, parent, path=None):
        """
        """
        wx.Panel.__init__(self, parent, id=-1)
        
        self.parent = parent
        self.path = path
        sizer = wx.BoxSizer(wx.VERTICAL)
        btnSizer = wx.BoxSizer(wx.HORIZONTAL)
        
        self.pdf = PDFWindow(self, style=wx.SUNKEN_BORDER)
        
        sizer.Add(self.pdf, proportion=1, flag=wx.EXPAND)
        
        btn = wx.Button(self, wx.NewId(), "Open PDF File")
        self.Bind(wx.EVT_BUTTON, self.OnOpenButton, btn)
        btnSizer.Add(btn, proportion=1, flag=wx.EXPAND|wx.ALL, border=5)

        self.pdf.LoadFile(self.path)
        btn = wx.Button(self, wx.NewId(), "Previous Page")
        self.Bind(wx.EVT_BUTTON, self.OnPrevPageButton, btn)
        btnSizer.Add(btn, proportion=1, flag=wx.EXPAND|wx.ALL, border=5)

        btn = wx.Button(self, wx.NewId(), "Next Page")
        self.Bind(wx.EVT_BUTTON, self.OnNextPageButton, btn)
        btnSizer.Add(btn, proportion=1, flag=wx.EXPAND|wx.ALL, border=5)
        
        btn = wx.Button(self, wx.NewId(), "Close")
        self.Bind(wx.EVT_BUTTON, self.OnClose, btn)
        btnSizer.Add(btn, proportion=1, flag=wx.EXPAND|wx.ALL, border=5)
        btnSizer.Add((50,-1), proportion=2, flag=wx.EXPAND)
        sizer.Add(btnSizer, proportion=0, flag=wx.EXPAND)

        self.SetSizer(sizer)
        self.SetAutoLayout(True)
        wx.EVT_CLOSE(self.parent, self.OnClose)
        
    def OnOpenButton(self, event):
        """
        Open file button
        """
        # make sure you have PDF files available on your drive
        dlg = wx.FileDialog(self, wildcard="*.pdf")
        dlg.SetDirectory(os.path.dirname(self.path))
        if dlg.ShowModal() == wx.ID_OK:
            wx.BeginBusyCursor()
            file = dlg.GetPath()
            self.pdf.LoadFile(file)
            self.parent.SetTitle(os.path.basename(file.split('.')[0]))
            wx.EndBusyCursor()
        dlg.Destroy()
        # Let Panel know the file changed: Avoiding C++ error
        self.Update()
        
    def OnLoad(self, event=None, path=None):
        """
        Load a pdf file
        
        : Param path: full path to the file
        """
        self.pdf.LoadFile(path)

        
    def OnPrevPageButton(self, event):
        """
        Goes to Previous page
        """
        self.pdf.gotoPreviousPage()

    def OnNextPageButton(self, event):
        """
        Goes to Next page
        """
        self.pdf.gotoNextPage()
        
    def OnClose(self, event):
        """
        Close panel
        """
        self.parent.Destroy()
Example #21
0
class PdfPanel(wx.Panel):
    def __init__(self, parent):
        wx.Panel.__init__(self, parent, id=-1)
        self.pdf = None
        sizer = wx.BoxSizer(wx.VERTICAL)

        if NOT_USE_ADOBE:
            self.pdf = wx.StaticText(
                self, -1,
                u"Cette fonctionnalité n'est disponible qu'avec Adobe Acrobat Reader\n"
            )
#            from wx.lib.pdfviewer import pdfViewer
#            self.pdf = pdfViewer( self, wx.NewId(), wx.DefaultPosition,
#                                wx.DefaultSize, wx.HSCROLL|wx.VSCROLL|wx.SUNKEN_BORDER)
        else:
            self.pdf = PDFWindow(self, style=wx.SUNKEN_BORDER)

#        if ADOBE_VERSION == None:
#            self.pdf = wx.StaticText(self, -1, u"Cette fonctionnalité n'est disponible qu'avec Adobe Acrobat Reader\n"\
#                                                   u"Pour obtenir le dossier de validation, passer par le menu Fichier/Générer le dossier de validation.")
#        else:
#            if ADOBE_VERSION[:3] == (11, 0, 7) or ADOBE_VERSION[:3] == (11, 0, 8):
#                self.pdf = wx.StaticText(self, -1, u"Cette fonctionnalité n'est pas compatible Adobe Acrobat Reader version 11.0.07 !!\n\n"\
#                                                   u"Pour visualiser le dossier de validation :\n"\
#                                                   u" - Passer à la version 10.0.09 - si disponible (http://get.adobe.com/fr/reader)\n" \
#                                                   u" - Utiliser la version 11.0.06 (http://www.adobe.com/support/downloads/product.jsp?product=10&platform=Windows)\n" \
#                                                   u" - Utiliser la version 10 (http://get.adobe.com/fr/reader/otherversions)\n" \
#                                                   u" - Générer le fichier .pdf : menu Fichier/Générer le dossier de validation projet")
#            elif get_min_adobe_version() != None:
#                self.pdf = PDFWindow(self, style=wx.SUNKEN_BORDER)
#            else:
#                self.pdf = wx.StaticText(self, -1, u"Cette fonctionnalité n'est disponible qu'avec Adobe Acrobat Reader\n"\
#                                                   u"Pour obtenir le dossier de validation, passer par le menu Fichier/Générer le dossier de validation.")
#        else:
#            self.pdf = pdfViewer( self, -1, wx.DefaultPosition,
#                                wx.DefaultSize, wx.HSCROLL|wx.VSCROLL|wx.SUNKEN_BORDER)
        sizer.Add(self.pdf, proportion=1, flag=wx.EXPAND)
        self.SetSizer(sizer)
        self.sizer = sizer
        self.SetAutoLayout(True)

        self.pdf.Bind(wx.EVT_ENTER_WINDOW, self.OnEnter)

    ######################################################################################################
    def OnEnter(self, event):
        print "OnEnter PDF"
        self.pdf.SetFocus()
        event.Skip()

    def MiseAJour(self, projet, fenDoc):
        if isinstance(self.pdf, wx.StaticText):
            #        if get_min_adobe_version() == None:
            print "Problème version Adobe"
            return
#        if hasattr(self, 'dosstemp') and get_min_adobe_version() == None:
#            shutil.rmtree(self.dosstemp)
        self.dosstemp = tempfile.mkdtemp()
        fichertemp = os.path.join(self.dosstemp, "pdfdoss.pdf")

        wx.BeginBusyCursor()
        Ok = genererDossierValidation(fichertemp, projet, fenDoc)
        if Ok:
            if not self.chargerFichierPDF(fichertemp):
                wx.EndBusyCursor()
                return
#            try:
#                self.pdf.LoadFile(fichertemp)
#            except:
#                print "ERREUR PDF"
#                wx.EndBusyCursor()
#                return

        if True:  #get_min_adobe_version() != None:
            try:
                shutil.rmtree(self.dosstemp)
            except:
                time.sleep(.5)
                try:
                    shutil.rmtree(self.dosstemp)
                except:
                    pass

        wx.EndBusyCursor()
        if not Ok:
            self.pdf = wx.StaticText(
                self, -1,
                u"Un des textes descriptifs du projet est trop grand !")
            self.sizer.Add(self.pdf, proportion=1, flag=wx.EXPAND)

    def chargerFichierPDF(self, nomFichier):
        if isinstance(self.pdf, wx.StaticText):
            return

        if NOT_USE_ADOBE:
            try:
                self.pdf.LoadFile(nomFichier)
            except:
                print "ERREUR pdfViewer", self.pdf
        else:
            try:
                self.pdf.LoadFile(nomFichier)
            except:
                print "ERREUR PDFWindow", self.pdf
Example #22
0
class My_Frame(wx.Frame):
    def __init__(self, parent, id, title):
        wx.Frame.__init__(self,
                          parent,
                          -1,
                          title,
                          size=(720, 600),
                          style=wx.DEFAULT_FRAME_STYLE
                          | wx.NO_FULL_REPAINT_ON_RESIZE)

        #------------

        # Simplified init method.
        self.CreateCtrls()
        self.LoadPdf()
        self.BindEvents()
        self.DoLayout()

        #---------------------------------------------------------------

        self.CenterOnScreen()

    #-------------------------------------------------------------------

    def CreateCtrls(self):
        """
        ...
        """

        fontSize = self.GetFont().GetPointSize()
        boldFont = wx.Font(fontSize, wx.SWISS, wx.NORMAL, wx.BOLD)

        #------------

        self.panel = wx.Panel(self, -1)

        #------------

        # Add PDFWindow
        self.pdf = PDFWindow(self.panel, style=wx.SUNKEN_BORDER)
        self.pdf.setView("FitV")
        self.pdf.setPageMode("Bookmarks")
        self.pdf.setLayoutMode("SinglePage")
        self.pdf.setShowScrollbars(True)

        #------------

        # Add controls
        self.btn1 = wx.Button(self.panel, -1, "&Open")
        self.btn1.SetToolTip("Open PDF file.")

        self.btn2 = wx.Button(self.panel, -1, "<<", size=(30, -1))
        self.btn2.SetToolTip("First page.")
        self.btn2.SetFont(boldFont)

        self.btn3 = wx.Button(self.panel, -1, "<", size=(30, -1))
        self.btn3.SetToolTip("Previous page.")
        self.btn3.SetFont(boldFont)

        self.btn4 = wx.Button(self.panel, -1, ">", size=(30, -1))
        self.btn4.SetToolTip("Next page.")
        self.btn4.SetFont(boldFont)

        self.btn5 = wx.Button(self.panel, -1, ">>", size=(30, -1))
        self.btn5.SetToolTip("Last page.")
        self.btn5.SetFont(boldFont)

        self.txt1 = wx.StaticText(self.panel, -1, "   Go to page")
        self.txtCtrl = wx.TextCtrl(self.panel, -1, "0", size=[30, -1])

        self.txt2 = wx.StaticText(self.panel, -1, "     Zoom")
        self.zoom = wx.Choice(self.panel,
                              -1,
                              choices=[
                                  "Default", "Fit", "FitH", "FitV", "25%",
                                  "50%", "75%", "100%", "125%", "200%", "400%"
                              ])
        self.zoom.SetSelection(0)
        self.zoom.SetToolTip("Zoom.")

        self.btn6 = wx.Button(self.panel, -1, "&Pr&int")
        self.btn6.SetToolTip("Print PDF file.")

        self.btn7 = wx.Button(self.panel, -1, "&Quit")
        self.btn7.SetToolTip("Quit application.")

    def BindEvents(self):
        """
        Bind all the events related to my frame.
        """

        self.Bind(wx.EVT_BUTTON, self.OnOpenBtn, self.btn1)
        self.Bind(wx.EVT_BUTTON, self.OnFirstPageBtn, self.btn2)
        self.Bind(wx.EVT_BUTTON, self.OnPrevPageBtn, self.btn3)
        self.Bind(wx.EVT_BUTTON, self.OnNextPageBtn, self.btn4)
        self.Bind(wx.EVT_BUTTON, self.OnLastPageBtn, self.btn5)
        self.Bind(wx.EVT_BUTTON, self.OnPrintBtn, self.btn6)
        self.Bind(wx.EVT_BUTTON, self.OnCloseBtn, self.btn7)

        self.Bind(wx.EVT_TEXT, self.OnGotoPage, self.txtCtrl)
        self.Bind(wx.EVT_CHOICE, self.OnZoom, self.zoom)

        self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
        self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground)

    def DoLayout(self):
        """
        Manage widgets Layout.
        """

        # MainSizer is the top-level one that manages everything.
        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(self.pdf, proportion=1, flag=wx.EXPAND)

        #------------

        btnSizer = wx.BoxSizer(wx.HORIZONTAL)
        btnSizer.Add(self.btn1,
                     proportion=0,
                     flag=wx.ALIGN_CENTER | wx.ALL,
                     border=5)
        btnSizer.Add(self.btn2,
                     proportion=0,
                     flag=wx.ALIGN_CENTER | wx.ALL,
                     border=2)
        btnSizer.Add(self.btn3,
                     proportion=0,
                     flag=wx.ALIGN_CENTER | wx.ALL,
                     border=2)
        btnSizer.Add(self.btn4,
                     proportion=0,
                     flag=wx.ALIGN_CENTER | wx.ALL,
                     border=2)
        btnSizer.Add(self.btn5,
                     proportion=0,
                     flag=wx.ALIGN_CENTER | wx.ALL,
                     border=2)
        btnSizer.Add(self.txt1,
                     proportion=0,
                     flag=wx.ALIGN_CENTER | wx.ALL,
                     border=5)
        btnSizer.Add(self.txtCtrl,
                     proportion=0,
                     flag=wx.ALIGN_CENTER | wx.ALL,
                     border=5)
        btnSizer.Add(self.txt2,
                     proportion=0,
                     flag=wx.ALIGN_CENTER | wx.ALL,
                     border=5)
        btnSizer.Add(self.zoom,
                     proportion=0,
                     flag=wx.ALIGN_CENTER | wx.ALL,
                     border=5)
        btnSizer.Add(self.btn6,
                     proportion=0,
                     flag=wx.ALIGN_CENTER | wx.ALL,
                     border=5)
        btnSizer.Add(self.btn7,
                     proportion=0,
                     flag=wx.ALIGN_CENTER | wx.ALL,
                     border=5)
        btnSizer.Add((50, -1), proportion=2, flag=wx.EXPAND)

        #------------

        sizer.Add(btnSizer, proportion=0, flag=wx.EXPAND)

        #------------

        # Finally, tell the panel to use the mainSizer for layout.
        self.panel.SetSizer(sizer)
        self.panel.SetAutoLayout(True)

    def LoadPdf(self):
        """
        ...
        """

        self.pdf.LoadFile(doc)

    def OnOpenBtn(self, event):
        """
        ...
        """

        dlg = wx.FileDialog(self, wildcard="*.pdf")

        if dlg.ShowModal() == wx.ID_OK:
            wx.BeginBusyCursor()
            self.pdf.LoadFile(dlg.GetPath())
            wx.EndBusyCursor()

        dlg.Destroy()

    def OnFirstPageBtn(self, event):
        """
        ...
        """

        self.pdf.gotoFirstPage()

    def OnPrevPageBtn(self, event):
        """
        ...
        """

        self.pdf.gotoPreviousPage()

    def OnNextPageBtn(self, event):
        """
        ...
        """

        self.pdf.gotoNextPage()

    def OnLastPageBtn(self, event):
        """
        ...
        """

        self.pdf.gotoLastPage()

    def OnGotoPage(self, event):
        """
        ...
        """

        npage = event.GetEventObject().GetValue()

        try:
            self.pdf.setCurrentPage(int(npage))
        except ValueError:
            pass

    def OnZoom(self, event):
        """
        ...
        """

        astring = event.GetEventObject().GetStringSelection()

        if astring.startswith('Fit'):
            self.pdf.setView(astring)
        else:
            try:
                percent = float(astring.replace('%', ''))
                self.pdf.setZoom(percent)
            except ValueError:
                pass

    def OnPrintBtn(self, event):
        """
        ...
        """

        self.pdf.Print()

    def OnCloseBtn(self, event):
        """
        ...
        """

        self.Close(True)

    def OnEraseBackground(self, event):
        """
        ...
        """

        dc = event.GetDC()

        if not dc:
            dc = wx.ClientDC(self)
            rect = self.GetUpdateRegion().GetBox()
            dc.SetClippingRect(rect)

    def OnCloseWindow(self, event):
        """
        ...
        """

        self.Destroy()
Example #23
0
class TestPanel(wx.Panel):
    def __init__(self, parent, log):
        wx.Panel.__init__(self, parent, -1)

        mainsizer = wx.BoxSizer(wx.HORIZONTAL)
        leftsizer = wx.BoxSizer(wx.VERTICAL)
        self.pdf = PDFWindow(self, style=wx.SUNKEN_BORDER)
        leftsizer.Add(self.pdf, proportion=1, flag=wx.EXPAND)

        box = wx.StaticBox(self, wx.NewId(), "" )
        buttonsizer = wx.StaticBoxSizer(box, wx.HORIZONTAL )
    
        b1 = wx.Button(self, wx.NewId(), "First")
        buttonsizer.Add(b1, proportion=0, flag=wx.ALIGN_CENTER|wx.ALL, border=5)
        self.Bind(wx.EVT_BUTTON, self.OnFirstPageButton, b1)

        b2 = wx.Button(self,  wx.NewId(), "Previous")
        buttonsizer.Add(b2, proportion=0, flag=wx.ALIGN_CENTER|wx.ALL, border=5)
        self.Bind(wx.EVT_BUTTON, self.OnPreviousPageButton, b2)
        
        tx1 = wx.StaticText(self, wx.NewId(), "   Go to page" )
        buttonsizer.Add(tx1, proportion=0, flag=wx.ALIGN_CENTER|wx.ALL, border=5)
        tc1 = wx.TextCtrl(self, wx.NewId(), "0", size=[30,-1])
        buttonsizer.Add( tc1, proportion=0, flag=wx.ALIGN_CENTER|wx.ALL, border=5)
        self.Bind(wx.EVT_TEXT, self.OnGotoPage, tc1)
    
        b3 = wx.Button(self, wx.NewId(), "Next")
        buttonsizer.Add(b3, proportion=0, flag=wx.ALIGN_CENTER|wx.ALL, border=5)
        self.Bind(wx.EVT_BUTTON, self.OnNextPageButton, b3)

        b4 = wx.Button(self, wx.NewId(), "Last")
        buttonsizer.Add(b4, proportion=0, flag=wx.ALIGN_CENTER|wx.ALL, border=5)
        self.Bind(wx.EVT_BUTTON, self.OnLastPageButton, b4)

        tx2 = wx.StaticText(self, wx.NewId(), "     Zoom")
        buttonsizer.Add(tx2, proportion=0, flag=wx.ALIGN_CENTER|wx.ALL, border=5)
 
        ch1 = wx.Choice(self, wx.NewId(),
                        choices=["Default", "Fit", "FitH", "FitV",
                                 "25%", "50%", "75%", "100%", "125%", "200%", "400%"])
        ch1.SetSelection(0)
        buttonsizer.Add(ch1, proportion=0, flag=wx.ALIGN_CENTER|wx.ALL, border=5)
        self.Bind(wx.EVT_CHOICE, self.OnZoom, ch1)

        leftsizer.Add(buttonsizer, proportion=0)
        mainsizer.Add(leftsizer, proportion=1, flag=wx.GROW|wx.ALIGN_CENTER_HORIZONTAL|wx.ALL, border=5)

        box = wx.StaticBox(self, wx.NewId(), "" )
        rightsizer = wx.StaticBoxSizer(box, wx.VERTICAL)
    
        b5 = wx.Button(self, wx.NewId(), "Load PDF")
        rightsizer.Add(b5, proportion=0, flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL, border=5)
        self.Bind(wx.EVT_BUTTON, self.OnLoadButton, b5)

        b6 = wx.Button(self, wx.NewId(), "Print")
        rightsizer.Add(b6, proportion=0, flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL, border=5)
        self.Bind(wx.EVT_BUTTON, self.OnPrintButton, b6)

        tx3 = wx.StaticText(self, wx.NewId(), "Page mode:")
        rightsizer.Add(tx3, proportion=0, flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL, border=5)

        ch2 = wx.Choice(self, wx.NewId(),size=[100,-1],
                        choices=["None", "Bookmarks", "Thumbs"])
        ch2.SetSelection(0)
        rightsizer.Add(ch2, proportion=0, flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL, border=5)
        self.Bind(wx.EVT_CHOICE, self.OnPageMode, ch2)

        tx4 = wx.StaticText(self, wx.NewId(), "Layout mode:")
        rightsizer.Add(tx4, proportion=0, flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL, border=5)

        ch3 = wx.Choice(self, wx.NewId(),size=[100,-1],
                        choices=["DontCare", "SinglePage",
                                 "OneColumn", "TwoColumnLeft", "TwoColumnRight" ])
        ch3.SetSelection(0)
        rightsizer.Add(ch3, proportion=0, flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL, border=5)
        self.Bind(wx.EVT_CHOICE, self.OnLayoutMode, ch3)

        cx1 = wx.CheckBox(self, wx.NewId(), "Toolbar")
        cx1.SetValue( True )
        rightsizer.Add( cx1,proportion=0, flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL, border=5)
        self.Bind(wx.EVT_CHECKBOX, self.OnToolbar, cx1)

        cx2 = wx.CheckBox(self, wx.NewId(), "Scrollbars")
        cx2.SetValue( True )
        rightsizer.Add( cx2,proportion=0, flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL, border=5)
        self.Bind(wx.EVT_CHECKBOX, self.OnScrollbars, cx2)

        mainsizer.Add( rightsizer, proportion=0, flag=wx.ALL, border=15)
        self.SetSizer(mainsizer)
        self.SetAutoLayout(True)

    def OnFirstPageButton(self, event):
        self.pdf.gotoFirstPage()

    def OnPreviousPageButton(self, event):
        self.pdf.gotoPreviousPage()

    def OnNextPageButton(self, event):
        self.pdf.gotoNextPage()

    def OnLastPageButton(self, event):
        self.pdf.gotoLastPage()

    def OnGotoPage(self, event):
        npage = event.GetEventObject().GetValue()
        try:
            self.pdf.setCurrentPage(int(npage))
        except ValueError:
            pass

    def OnZoom(self, event):
        astring = event.GetEventObject().GetStringSelection()
        if astring.startswith('Fit'):
            self.pdf.setView(astring)
        else:
            try:
                percent = float(astring.replace('%',''))
                self.pdf.setZoom(percent)
            except ValueError:
                pass
        
    def OnLoadButton(self, event):
        dlg = wx.FileDialog(self, wildcard="*.pdf")
        if dlg.ShowModal() == wx.ID_OK:
            wx.BeginBusyCursor()
            self.pdf.LoadFile(dlg.GetPath())
            wx.EndBusyCursor()
        dlg.Destroy()

    def OnPrintButton(self, event):
        self.pdf.Print()

    def OnPageMode(self, event):
        astring = event.GetEventObject().GetStringSelection()
        self.pdf.setPageMode(astring.lower())

    def OnLayoutMode(self, event):
        astring = event.GetEventObject().GetStringSelection()
        self.pdf.setLayoutMode(astring)

    def OnToolbar(self, event):
        on = event.GetEventObject().GetValue()
        self.pdf.setShowToolbar(on)

    def OnScrollbars(self, event):
        on = event.GetEventObject().GetValue()
        self.pdf.setShowScrollbars(on)
Example #24
0
    def CreateCtrls(self):
        """
        ...
        """

        fontSize = self.GetFont().GetPointSize()
        boldFont = wx.Font(fontSize, wx.SWISS, wx.NORMAL, wx.BOLD)

        #------------

        self.panel = wx.Panel(self, -1)

        #------------

        # Add PDFWindow
        self.pdf = PDFWindow(self.panel, style=wx.SUNKEN_BORDER)
        self.pdf.setView("FitV")
        self.pdf.setPageMode("Bookmarks")
        self.pdf.setLayoutMode("SinglePage")
        self.pdf.setShowScrollbars(True)

        #------------

        # Add controls
        self.btn1 = wx.Button(self.panel, -1, "&Open")
        self.btn1.SetToolTip("Open PDF file.")

        self.btn2 = wx.Button(self.panel, -1, "<<", size=(30, -1))
        self.btn2.SetToolTip("First page.")
        self.btn2.SetFont(boldFont)

        self.btn3 = wx.Button(self.panel, -1, "<", size=(30, -1))
        self.btn3.SetToolTip("Previous page.")
        self.btn3.SetFont(boldFont)

        self.btn4 = wx.Button(self.panel, -1, ">", size=(30, -1))
        self.btn4.SetToolTip("Next page.")
        self.btn4.SetFont(boldFont)

        self.btn5 = wx.Button(self.panel, -1, ">>", size=(30, -1))
        self.btn5.SetToolTip("Last page.")
        self.btn5.SetFont(boldFont)

        self.txt1 = wx.StaticText(self.panel, -1, "   Go to page")
        self.txtCtrl = wx.TextCtrl(self.panel, -1, "0", size=[30, -1])

        self.txt2 = wx.StaticText(self.panel, -1, "     Zoom")
        self.zoom = wx.Choice(self.panel,
                              -1,
                              choices=[
                                  "Default", "Fit", "FitH", "FitV", "25%",
                                  "50%", "75%", "100%", "125%", "200%", "400%"
                              ])
        self.zoom.SetSelection(0)
        self.zoom.SetToolTip("Zoom.")

        self.btn6 = wx.Button(self.panel, -1, "&Pr&int")
        self.btn6.SetToolTip("Print PDF file.")

        self.btn7 = wx.Button(self.panel, -1, "&Quit")
        self.btn7.SetToolTip("Quit application.")