]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/ActiveX_PDFWindow.py
4 if wx
.Platform
== '__WXMSW__':
5 from wx
.lib
.pdfwin
import PDFWindow
8 #----------------------------------------------------------------------
10 class TestPanel(wx
.Panel
):
11 def __init__(self
, parent
, log
):
12 wx
.Panel
.__init
__(self
, parent
, -1)
15 sizer
= wx
.BoxSizer(wx
.VERTICAL
)
16 btnSizer
= wx
.BoxSizer(wx
.HORIZONTAL
)
18 self
.pdf
= PDFWindow(self
, style
=wx
.SUNKEN_BORDER
)
20 sizer
.Add(self
.pdf
, proportion
=1, flag
=wx
.EXPAND
)
22 btn
= wx
.Button(self
, wx
.NewId(), "Open PDF File")
23 self
.Bind(wx
.EVT_BUTTON
, self
.OnOpenButton
, btn
)
24 btnSizer
.Add(btn
, proportion
=1, flag
=wx
.EXPAND|wx
.ALL
, border
=5)
26 btn
= wx
.Button(self
, wx
.NewId(), "<-- Previous Page")
27 self
.Bind(wx
.EVT_BUTTON
, self
.OnPrevPageButton
, btn
)
28 btnSizer
.Add(btn
, proportion
=1, flag
=wx
.EXPAND|wx
.ALL
, border
=5)
30 btn
= wx
.Button(self
, wx
.NewId(), "Next Page -->")
31 self
.Bind(wx
.EVT_BUTTON
, self
.OnNextPageButton
, btn
)
32 btnSizer
.Add(btn
, proportion
=1, flag
=wx
.EXPAND|wx
.ALL
, border
=5)
35 btnSizer
.Add((50,-1), proportion
=2, flag
=wx
.EXPAND
)
36 sizer
.Add(btnSizer
, proportion
=0, flag
=wx
.EXPAND
)
39 self
.SetAutoLayout(True)
43 def OnOpenButton(self
, event
):
44 dlg
= wx
.FileDialog(self
, wildcard
="*.pdf")
46 if dlg
.ShowModal() == wx
.ID_OK
:
48 self
.pdf
.LoadFile(dlg
.GetPath())
54 def OnPrevPageButton(self
, event
):
55 self
.pdf
.gotoPreviousPage()
58 def OnNextPageButton(self
, event
):
59 self
.pdf
.gotoNextPage()
63 #----------------------------------------------------------------------
65 def runTest(frame
, nb
, log
):
66 if wx
.Platform
== '__WXMSW__':
67 win
= TestPanel(nb
, log
)
70 dlg
= wx
.MessageDialog(frame
, 'This demo only works on MSW.',
71 'Sorry', wx
.OK | wx
.ICON_INFORMATION
)
76 overview
= """\<html><body>
77 <h2>wx.lib.pdfwin.PDFWindow</h2>
79 The wx.lib.pdfwin.PDFWindow class is another example of using ActiveX
80 controls from wxPython using the new wx.activex module. This allows
81 you to use an ActiveX control as if it is a wx.Window, you can call
82 its methods, set/get properties, and receive events from the ActiveX
83 control in a very intuitive way.
85 <p> Using this class is simpler than ActiveXWrapper, doesn't rely on
86 the win32all extensions, and is more "wx\'ish", meaning that it uses
87 events and etc. as would be expected from any other wx window.
89 <p> This demo embeds the Adobe Acrobat Reader, and gives you some
90 buttons for opening a PDF file, changing pages, etc. that show how to
91 call methods on the COM object. If you don't have Acrobat Reader 4.0
92 (or greater) installed it won't work.
97 #----------------------------------------------------------------------
101 if __name__
== '__main__':
104 run
.main(['', os
.path
.basename(sys
.argv
[0])] + sys
.argv
[1:])