]> git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/ActiveX_PDFWindow.py
GetFirstChild does't need the cookie anymore
[wxWidgets.git] / wxPython / demo / ActiveX_PDFWindow.py
1 import sys
2 import wx
3
4 if wx.Platform == '__WXMSW__':
5 from wx.lib.pdfwin import PDFWindow
6
7
8 #----------------------------------------------------------------------
9
10 class 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
65 def 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
76 overview = """\<html><body>
77 <h2>wx.lib.pdfwin.PDFWindow</h2>
78
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.
84
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.
88
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.
93
94 </body></html>
95 """
96
97 #----------------------------------------------------------------------
98
99
100
101 if __name__ == '__main__':
102 import sys,os
103 import run
104 run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])
105
106