]> git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/ActiveX_PDFWindow.py
use WX_DEFINE_ARRAY_PTR for anarray of pointers (fixes Sun CC warning)
[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 from Main import MessagePanel
71 win = MessagePanel(nb, 'This demo only works on Microsoft Windows.',
72 'Sorry', wx.ICON_WARNING)
73 return win
74
75
76 overview = """\
77 <html><body>
78 <h2>wx.lib.pdfwin.PDFWindow</h2>
79
80 The wx.lib.pdfwin.PDFWindow class is another example of using ActiveX
81 controls from wxPython using the new wx.activex module. This allows
82 you to use an ActiveX control as if it is a wx.Window, you can call
83 its methods, set/get properties, and receive events from the ActiveX
84 control in a very intuitive way.
85
86 <p> Using this class is simpler than ActiveXWrapper, doesn't rely on
87 the win32all extensions, and is more "wx\'ish", meaning that it uses
88 events 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
91 buttons for opening a PDF file, changing pages, etc. that show how to
92 call 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
102 if __name__ == '__main__':
103 import sys,os
104 import run
105 run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])
106
107