Demo updates for new wx namespace, from Jeff Grimmett

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@24723 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2003-12-09 01:23:28 +00:00
parent a61d40115f
commit 8fa876ca9e
147 changed files with 7313 additions and 5154 deletions

View File

@@ -13,58 +13,65 @@ have Acrobat Reader 4.0 installed it won't work.
</body></html>
"""
from wxPython.wx import *
# 11/24/2003 - Jeff Grimmett (grimmtooth@softhome.net)
#
# o Updated for 2.5
#
if wxPlatform == '__WXMSW__':
from wxPython.lib.activexwrapper import MakeActiveXClass
import win32com.client.gencache
import sys
import wx
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):
class TestPanel(wx.Panel):
def __init__(self, parent, log):
wxPanel.__init__(self, parent, -1)
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)
EVT_WINDOW_DESTROY(self, self.OnDestroy)
self.Bind(wx.EVT_WINDOW_DESTROY, self.OnDestroy)
def OnDestroy(self, evt):
@@ -75,11 +82,12 @@ class TestPanel(wxPanel):
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()
@@ -96,12 +104,12 @@ class TestPanel(wxPanel):
#----------------------------------------------------------------------
def runTest(frame, nb, log):
if wxPlatform == '__WXMSW__':
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()
@@ -112,17 +120,19 @@ overview = __doc__
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)
wx.Frame.__init__(
self, None, -1, "ActiveX test -- Acrobat", size=(640, 480),
style=wx.DEFAULT_FRAME_STYLE|wx.NO_FULL_REPAINT_ON_RESIZE
)
self.tp = TestPanel(self, sys.stdout)
app = wxPySimpleApp()
app = wx.PySimpleApp()
frame = TestFrame()
frame.Show(True)
app.MainLoop()