]> git.saurik.com Git - wxWidgets.git/blame - wxPython/demo/ActiveX_PDFWindow.py
Made more useable from the command-line, since that is its primary purpose.
[wxWidgets.git] / wxPython / demo / ActiveX_PDFWindow.py
CommitLineData
b7c75283
RD
1import sys
2import wx
3
4if wx.Platform == '__WXMSW__':
5 from wx.lib.pdfwin import PDFWindow
6
7
8#----------------------------------------------------------------------
9
10class TestPanel(wx.Panel):
11 def __init__(self, parent, log):
12 wx.Panel.__init__(self, parent, -1)
13 self.pdf = None
14
15 sizer = wx.BoxSizer(wx.VERTICAL)
16 btnSizer = wx.BoxSizer(wx.HORIZONTAL)
17
18 self.pdf = PDFWindow(self, style=wx.SUNKEN_BORDER)
19
20 sizer.Add(self.pdf, proportion=1, flag=wx.EXPAND)
21
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)
25
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)
29
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)
33
34
35 btnSizer.Add((50,-1), proportion=2, flag=wx.EXPAND)
36 sizer.Add(btnSizer, proportion=0, flag=wx.EXPAND)
37
38 self.SetSizer(sizer)
39 self.SetAutoLayout(True)
40
41
42
43 def OnOpenButton(self, event):
44 dlg = wx.FileDialog(self, wildcard="*.pdf")
45
46 if dlg.ShowModal() == wx.ID_OK:
47 wx.BeginBusyCursor()
48 self.pdf.LoadFile(dlg.GetPath())
49 wx.EndBusyCursor()
50
51 dlg.Destroy()
52
53
54 def OnPrevPageButton(self, event):
55 self.pdf.gotoPreviousPage()
56
57
58 def OnNextPageButton(self, event):
59 self.pdf.gotoNextPage()
60
61
62
63#----------------------------------------------------------------------
64
65def runTest(frame, nb, log):
66 if wx.Platform == '__WXMSW__':
67 win = TestPanel(nb, log)
68 return win
69 else:
70 dlg = wx.MessageDialog(frame, 'This demo only works on MSW.',
71 'Sorry', wx.OK | wx.ICON_INFORMATION)
72 dlg.ShowModal()
73 dlg.Destroy()
74
75
3c8ad70a
RD
76overview = """\
77<html><body>
b7c75283
RD
78<h2>wx.lib.pdfwin.PDFWindow</h2>
79
80The wx.lib.pdfwin.PDFWindow class is another example of using ActiveX
81controls from wxPython using the new wx.activex module. This allows
82you to use an ActiveX control as if it is a wx.Window, you can call
83its methods, set/get properties, and receive events from the ActiveX
84control in a very intuitive way.
85
86<p> Using this class is simpler than ActiveXWrapper, doesn't rely on
87the win32all extensions, and is more "wx\'ish", meaning that it uses
88events and etc. as would be expected from any other wx window.
89
90<p> This demo embeds the Adobe Acrobat Reader, and gives you some
91buttons for opening a PDF file, changing pages, etc. that show how to
92call methods on the COM object. If you don't have Acrobat Reader 4.0
93(or greater) installed it won't work.
94
95</body></html>
96"""
97
98#----------------------------------------------------------------------
99
100
101
102if __name__ == '__main__':
103 import sys,os
104 import run
105 run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])
106
107