</body></html>
"""
-from wxPython.wx import *
+import sys
+import wx
-if wxPlatform == '__WXMSW__':
- from wxPython.lib.activexwrapper import MakeActiveXClass
- import win32com.client.gencache
+if wx.Platform == '__WXMSW__':
+ import wx.lib.activexwrapper as ax
+ import win32com.client.gencache
try:
- acrobat = win32com.client.gencache.EnsureModule('{CA8A9783-280D-11CF-A24D-444553540000}', 0x0, 1, 3)
+ acrobat = win32com.client.gencache.EnsureModule(
+ '{CA8A9783-280D-11CF-A24D-444553540000}', 0x0, 1, 3
+ )
except:
raise ImportError("Can't load PDF.OCX, install Acrobat 4.0")
-
#----------------------------------------------------------------------
-class TestPanel(wxPanel):
- def __init__(self, parent):
- wxPanel.__init__(self, parent, -1)
+class TestPanel(wx.Panel):
+ def __init__(self, parent, log):
+ wx.Panel.__init__(self, parent, -1)
self.pdf = None
- sizer = wxBoxSizer(wxVERTICAL)
- btnSizer = wxBoxSizer(wxHORIZONTAL)
+ sizer = wx.BoxSizer(wx.VERTICAL)
+ btnSizer = wx.BoxSizer(wx.HORIZONTAL)
# this function creates a new class that can be used as
- # a wxWindow, but contains the given ActiveX control.
- ActiveXWrapper = MakeActiveXClass(acrobat.Pdf)
+ # a wx.Window, but contains the given ActiveX control.
+ ActiveXWrapper = ax.MakeActiveXClass(acrobat.Pdf)
# create an instance of the new class
- self.pdf = ActiveXWrapper( self, -1, style=wxSUNKEN_BORDER)
+ self.pdf = ActiveXWrapper( self, -1, style=wx.SUNKEN_BORDER)
- sizer.Add(self.pdf, 1, wxEXPAND)
+ sizer.Add(self.pdf, proportion=1, flag=wx.EXPAND)
- btn = wxButton(self, wxNewId(), "Open PDF File")
- EVT_BUTTON(self, btn.GetId(), self.OnOpenButton)
- btnSizer.Add(btn, 1, wxEXPAND|wxALL, 5)
+ btn = wx.Button(self, wx.NewId(), "Open PDF File")
+ self.Bind(wx.EVT_BUTTON, self.OnOpenButton)
+ btnSizer.Add(btn, proportion=1, flag=wx.EXPAND|wx.ALL, border=5)
- btn = wxButton(self, wxNewId(), "<-- Previous Page")
- EVT_BUTTON(self, btn.GetId(), self.OnPrevPageButton)
- btnSizer.Add(btn, 1, wxEXPAND|wxALL, 5)
+ btn = wx.Button(self, wx.NewId(), "<-- Previous Page")
+ self.Bind(wx.EVT_BUTTON, self.OnPrevPageButton, id=btn.GetId())
+ btnSizer.Add(btn, proportion=1, flag=wx.EXPAND|wx.ALL, border=5)
- btn = wxButton(self, wxNewId(), "Next Page -->")
- EVT_BUTTON(self, btn.GetId(), self.OnNextPageButton)
- btnSizer.Add(btn, 1, wxEXPAND|wxALL, 5)
+ btn = wx.Button(self, wx.NewId(), "Next Page -->")
+ self.Bind(wx.EVT_BUTTON, self.OnNextPageButton, id=btn.GetId())
+ btnSizer.Add(btn, proportion=1, flag=wx.EXPAND|wx.ALL, border=5)
- btnSizer.Add(50, -1, 2, wxEXPAND)
- sizer.Add(btnSizer, 0, wxEXPAND)
+ btnSizer.Add((50,-1), proportion=2, flag=wx.EXPAND)
+ sizer.Add(btnSizer, proportion=0, flag=wx.EXPAND)
self.SetSizer(sizer)
- self.SetAutoLayout(true)
+ self.SetAutoLayout(True)
+
+ self.Bind(wx.EVT_WINDOW_DESTROY, self.OnDestroy)
- def __del__(self):
+
+ def OnDestroy(self, evt):
if self.pdf:
self.pdf.Cleanup()
self.pdf = None
def OnOpenButton(self, event):
- dlg = wxFileDialog(self, wildcard="*.pdf")
- if dlg.ShowModal() == wxID_OK:
- wxBeginBusyCursor()
+ dlg = wx.FileDialog(self, wildcard="*.pdf")
+
+ if dlg.ShowModal() == wx.ID_OK:
+ wx.BeginBusyCursor()
self.pdf.LoadFile(dlg.GetPath())
- wxEndBusyCursor()
+ wx.EndBusyCursor()
dlg.Destroy()
#----------------------------------------------------------------------
def runTest(frame, nb, log):
- if wxPlatform == '__WXMSW__':
- win = TestPanel(nb)
+ if wx.Platform == '__WXMSW__':
+ win = TestPanel(nb, log)
return win
else:
- dlg = wxMessageDialog(frame, 'This demo only works on MSW.',
- 'Sorry', wxOK | wxICON_INFORMATION)
+ dlg = wx.MessageDialog(frame, 'This demo only works on MSW.',
+ 'Sorry', wx.OK | wx.ICON_INFORMATION)
dlg.ShowModal()
dlg.Destroy()
if __name__ == '__main__':
- class TestFrame(wxFrame):
+ class TestFrame(wx.Frame):
def __init__(self):
- wxFrame.__init__(self, None, -1, "ActiveX test -- Acrobat", size=(640, 480),
- style=wxDEFAULT_FRAME_STYLE|wxNO_FULL_REPAINT_ON_RESIZE)
- self.tp = TestPanel(self, sys.stdout)
- EVT_CLOSE(self, self.OnCloseWindow)
+ wx.Frame.__init__(
+ self, None, -1, "ActiveX test -- Acrobat", size=(640, 480),
+ style=wx.DEFAULT_FRAME_STYLE|wx.NO_FULL_REPAINT_ON_RESIZE
+ )
- def OnCloseWindow(self, event):
- self.tp.pdf.Cleanup()
- self.Destroy()
+ self.tp = TestPanel(self, sys.stdout)
- app = wxPySimpleApp()
+ app = wx.PySimpleApp()
frame = TestFrame()
- frame.Show(true)
+ frame.Show(True)
app.MainLoop()
-