Lindsay Mathieson's newest wxActiveX class has been wrapped into a new

extension module called wx.activex.  Lots of demo and lib updates to
go along with it.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@26301 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2004-03-23 05:29:50 +00:00
parent 13baae2c95
commit b7c75283f2
98 changed files with 16994 additions and 21 deletions

View File

@@ -0,0 +1,104 @@
import os
import wx
if wx.Platform == '__WXMSW__':
from wx.lib.flashwin import FlashWindow
from Main import opj
#----------------------------------------------------------------------
class TestPanel(wx.Panel):
def __init__(self, parent, log):
wx.Panel.__init__(self, parent, -1)
self.pdf = None
sizer = wx.BoxSizer(wx.VERTICAL)
btnSizer = wx.BoxSizer(wx.HORIZONTAL)
self.flash = FlashWindow(self, style=wx.SUNKEN_BORDER)
self.flash.LoadMovie(0, 'file://' + os.path.abspath('data/Asteroid_blaster.swf'))
sizer.Add(self.flash, proportion=1, flag=wx.EXPAND)
btn = wx.Button(self, wx.NewId(), "Open Flash File")
self.Bind(wx.EVT_BUTTON, self.OnOpenFileButton, btn)
btnSizer.Add(btn, proportion=1, flag=wx.EXPAND|wx.ALL, border=5)
btn = wx.Button(self, wx.NewId(), "Open Flash URL")
self.Bind(wx.EVT_BUTTON, self.OnOpenURLButton, btn)
btnSizer.Add(btn, proportion=1, flag=wx.EXPAND|wx.ALL, border=5)
btnSizer.Add((50,-1), proportion=2, flag=wx.EXPAND)
sizer.Add(btnSizer, proportion=0, flag=wx.EXPAND)
self.SetSizer(sizer)
self.SetAutoLayout(True)
def OnOpenFileButton(self, event):
dlg = wx.FileDialog(self, wildcard="*.swf")
if dlg.ShowModal() == wx.ID_OK:
wx.BeginBusyCursor()
self.flash.LoadMovie(0, 'file://' + dlg.GetPath())
wx.EndBusyCursor()
dlg.Destroy()
def OnOpenURLButton(self, event):
dlg = wx.TextEntryDialog(self, "Enter a URL of a .swf file", "Enter URL")
if dlg.ShowModal() == wx.ID_OK:
wx.BeginBusyCursor()
# setting the movie property works too
self.flash.movie = dlg.GetValue()
wx.EndBusyCursor()
dlg.Destroy()
#----------------------------------------------------------------------
def runTest(frame, nb, log):
if wx.Platform == '__WXMSW__':
win = TestPanel(nb, log)
return win
else:
dlg = wx.MessageDialog(frame, 'This demo only works on MSW.',
'Sorry', wx.OK | wx.ICON_INFORMATION)
dlg.ShowModal()
dlg.Destroy()
overview = """\<html><body>
<h2>wx.lib.pdfwin.FlashWindow</h2>
The wx.lib.pdfwin.FlashWindow class is yet another example of using
ActiveX controls from wxPython using the new wx.activex module. This
allows you to use an ActiveX control as if it is a wx.Window, you can
call its methods, set/get properties, and receive events from the
ActiveX control in a very intuitive way.
<p> Using this class is simpler than ActiveXWrapper, doesn't rely on
the win32all extensions, and is more "wx\'ish", meaning that it uses
events and etc. as would be expected from any other wx window.
<p> This demo embeds the Shackwave Flash control, and lets you play a game.
</body></html>
"""
#----------------------------------------------------------------------
if __name__ == '__main__':
import sys,os
import run
run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])

View File

@@ -0,0 +1,225 @@
# 11/18/2003 - Jeff Grimmett (grimmtooth@softhome.net)
#
# o Updated for wx namespace
#
import wx
if wx.Platform == '__WXMSW__':
import wx.lib.iewin as iewin
#----------------------------------------------------------------------
class TestPanel(wx.Window):
def __init__(self, parent, log, frame=None):
wx.Window.__init__(
self, parent, -1,
style=wx.TAB_TRAVERSAL|wx.CLIP_CHILDREN|wx.NO_FULL_REPAINT_ON_RESIZE
)
self.log = log
self.current = "http://wxPython.org/"
self.frame = frame
if frame:
self.titleBase = frame.GetTitle()
sizer = wx.BoxSizer(wx.VERTICAL)
btnSizer = wx.BoxSizer(wx.HORIZONTAL)
self.ie = iewin.IEHtmlWindow(self, -1, style = wx.NO_FULL_REPAINT_ON_RESIZE)
btn = wx.Button(self, -1, "Open", style=wx.BU_EXACTFIT)
self.Bind(wx.EVT_BUTTON, self.OnOpenButton, btn)
btnSizer.Add(btn, 0, wx.EXPAND|wx.ALL, 2)
btn = wx.Button(self, -1, "Home", style=wx.BU_EXACTFIT)
self.Bind(wx.EVT_BUTTON, self.OnHomeButton, btn)
btnSizer.Add(btn, 0, wx.EXPAND|wx.ALL, 2)
btn = wx.Button(self, -1, "<--", style=wx.BU_EXACTFIT)
self.Bind(wx.EVT_BUTTON, self.OnPrevPageButton, btn)
btnSizer.Add(btn, 0, wx.EXPAND|wx.ALL, 2)
btn = wx.Button(self, -1, "-->", style=wx.BU_EXACTFIT)
self.Bind(wx.EVT_BUTTON, self.OnNextPageButton, btn)
btnSizer.Add(btn, 0, wx.EXPAND|wx.ALL, 2)
btn = wx.Button(self, -1, "Stop", style=wx.BU_EXACTFIT)
self.Bind(wx.EVT_BUTTON, self.OnStopButton, btn)
btnSizer.Add(btn, 0, wx.EXPAND|wx.ALL, 2)
btn = wx.Button(self, -1, "Search", style=wx.BU_EXACTFIT)
self.Bind(wx.EVT_BUTTON, self.OnSearchPageButton, btn)
btnSizer.Add(btn, 0, wx.EXPAND|wx.ALL, 2)
btn = wx.Button(self, -1, "Refresh", style=wx.BU_EXACTFIT)
self.Bind(wx.EVT_BUTTON, self.OnRefreshPageButton, btn)
btnSizer.Add(btn, 0, wx.EXPAND|wx.ALL, 2)
txt = wx.StaticText(self, -1, "Location:")
btnSizer.Add(txt, 0, wx.CENTER|wx.ALL, 2)
self.location = wx.ComboBox(
self, -1, "", style=wx.CB_DROPDOWN|wx.PROCESS_ENTER
)
self.Bind(wx.EVT_COMBOBOX, self.OnLocationSelect, self.location)
self.location.Bind(wx.EVT_KEY_UP, self.OnLocationKey)
self.location.Bind(wx.EVT_CHAR, self.IgnoreReturn)
btnSizer.Add(self.location, 1, wx.EXPAND|wx.ALL, 2)
sizer.Add(btnSizer, 0, wx.EXPAND)
sizer.Add(self.ie, 1, wx.EXPAND)
self.ie.LoadUrl(self.current)
self.location.Append(self.current)
self.SetSizer(sizer)
# Since this is a wxWindow we have to call Layout ourselves
self.Bind(wx.EVT_SIZE, self.OnSize)
# Hook up the event handlers for the IE window
self.Bind(iewin.EVT_BeforeNavigate2, self.OnBeforeNavigate2, self.ie)
self.Bind(iewin.EVT_NewWindow2, self.OnNewWindow2, self.ie)
self.Bind(iewin.EVT_DocumentComplete, self.OnDocumentComplete, self.ie)
##self.Bind(iewin.EVT_ProgressChange, self.OnProgressChange, self.ie)
self.Bind(iewin.EVT_StatusTextChange, self.OnStatusTextChange, self.ie)
self.Bind(iewin.EVT_TitleChange, self.OnTitleChange, self.ie)
def ShutdownDemo(self):
# put the frame title back
if self.frame:
self.frame.SetTitle(self.titleBase)
def OnSize(self, evt):
self.Layout()
def OnLocationSelect(self, evt):
url = self.location.GetStringSelection()
self.log.write('OnLocationSelect: %s\n' % url)
self.ie.Navigate(url)
def OnLocationKey(self, evt):
if evt.KeyCode() == wx.WXK_RETURN:
URL = self.location.GetValue()
self.location.Append(URL)
self.ie.Navigate(URL)
else:
evt.Skip()
def IgnoreReturn(self, evt):
if evt.GetKeyCode() != wx.WXK_RETURN:
evt.Skip()
def OnOpenButton(self, event):
dlg = wx.TextEntryDialog(self, "Open Location",
"Enter a full URL or local path",
self.current, wx.OK|wx.CANCEL)
dlg.CentreOnParent()
if dlg.ShowModal() == wx.ID_OK:
self.current = dlg.GetValue()
self.ie.Navigate(self.current)
dlg.Destroy()
def OnHomeButton(self, event):
self.ie.GoHome() ## ET Phone Home!
def OnPrevPageButton(self, event):
self.ie.GoBack()
def OnNextPageButton(self, event):
self.ie.GoForward()
def OnStopButton(self, evt):
self.ie.Stop()
def OnSearchPageButton(self, evt):
self.ie.GoSearch()
def OnRefreshPageButton(self, evt):
self.ie.Refresh(iewin.REFRESH_COMPLETELY)
def logEvt(self, evt):
pst = ""
for name in evt.paramList:
pst += " %s:%s " % (name, repr(getattr(evt, name)))
self.log.write('%s: %s\n' % (evt.eventName, pst))
def OnBeforeNavigate2(self, evt):
self.logEvt(evt)
def OnNewWindow2(self, evt):
self.logEvt(evt)
## evt.Veto() # TODO
def OnProgressChange(self, evt):
self.logEvt(evt)
def OnDocumentComplete(self, evt):
self.logEvt(evt)
self.current = evt.URL
self.location.SetValue(self.current)
def OnTitleChange(self, evt):
self.logEvt(evt)
if self.frame:
self.frame.SetTitle(self.titleBase + ' -- ' + evt.Text)
def OnStatusTextChange(self, evt):
self.logEvt(evt)
if self.frame:
self.frame.SetStatusText(evt.Text)
#----------------------------------------------------------------------
# for the demo framework...
def runTest(frame, nb, log):
if wx.Platform == '__WXMSW__':
win = TestPanel(nb, log, frame)
return win
else:
dlg = wx.MessageDialog(frame, 'This demo only works on Windows.',
'Sorry', wx.OK | wx.ICON_INFORMATION)
dlg.ShowModal()
dlg.Destroy()
overview = """\
<html><body>
<h2>wx.lib.iewin.IEHtmlWindow</h2>
The wx.lib.iewin.IEHtmlWindow class is one example of using ActiveX
controls from wxPython using the new wx.activex module. This allows
you to use an ActiveX control as if it is a wx.Window, you can call
its methods, set/get properties, and receive events from the ActiveX
control in a very intuitive way.
<p> Using this class is simpler than ActiveXWrapper, doesn't rely on
the win32all extensions, and is more "wx\'ish", meaning that it uses
events and etc. as would be expected from any other wx window.
</body></html>
"""
if __name__ == '__main__':
import sys,os
import run
run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])
#----------------------------------------------------------------------

View File

@@ -0,0 +1,106 @@
import sys
import wx
if wx.Platform == '__WXMSW__':
from wx.lib.pdfwin import PDFWindow
#----------------------------------------------------------------------
class TestPanel(wx.Panel):
def __init__(self, parent, log):
wx.Panel.__init__(self, parent, -1)
self.pdf = None
sizer = wx.BoxSizer(wx.VERTICAL)
btnSizer = wx.BoxSizer(wx.HORIZONTAL)
self.pdf = PDFWindow(self, style=wx.SUNKEN_BORDER)
sizer.Add(self.pdf, proportion=1, flag=wx.EXPAND)
btn = wx.Button(self, wx.NewId(), "Open PDF File")
self.Bind(wx.EVT_BUTTON, self.OnOpenButton, btn)
btnSizer.Add(btn, proportion=1, flag=wx.EXPAND|wx.ALL, border=5)
btn = wx.Button(self, wx.NewId(), "<-- Previous Page")
self.Bind(wx.EVT_BUTTON, self.OnPrevPageButton, btn)
btnSizer.Add(btn, proportion=1, flag=wx.EXPAND|wx.ALL, border=5)
btn = wx.Button(self, wx.NewId(), "Next Page -->")
self.Bind(wx.EVT_BUTTON, self.OnNextPageButton, btn)
btnSizer.Add(btn, proportion=1, flag=wx.EXPAND|wx.ALL, border=5)
btnSizer.Add((50,-1), proportion=2, flag=wx.EXPAND)
sizer.Add(btnSizer, proportion=0, flag=wx.EXPAND)
self.SetSizer(sizer)
self.SetAutoLayout(True)
def OnOpenButton(self, event):
dlg = wx.FileDialog(self, wildcard="*.pdf")
if dlg.ShowModal() == wx.ID_OK:
wx.BeginBusyCursor()
self.pdf.LoadFile(dlg.GetPath())
wx.EndBusyCursor()
dlg.Destroy()
def OnPrevPageButton(self, event):
self.pdf.gotoPreviousPage()
def OnNextPageButton(self, event):
self.pdf.gotoNextPage()
#----------------------------------------------------------------------
def runTest(frame, nb, log):
if wx.Platform == '__WXMSW__':
win = TestPanel(nb, log)
return win
else:
dlg = wx.MessageDialog(frame, 'This demo only works on MSW.',
'Sorry', wx.OK | wx.ICON_INFORMATION)
dlg.ShowModal()
dlg.Destroy()
overview = """\<html><body>
<h2>wx.lib.pdfwin.PDFWindow</h2>
The wx.lib.pdfwin.PDFWindow class is another example of using ActiveX
controls from wxPython using the new wx.activex module. This allows
you to use an ActiveX control as if it is a wx.Window, you can call
its methods, set/get properties, and receive events from the ActiveX
control in a very intuitive way.
<p> Using this class is simpler than ActiveXWrapper, doesn't rely on
the win32all extensions, and is more "wx\'ish", meaning that it uses
events and etc. as would be expected from any other wx window.
<p> This demo embeds the Adobe Acrobat Reader, and gives you some
buttons for opening a PDF file, changing pages, etc. that show how to
call methods on the COM object. If you don't have Acrobat Reader 4.0
(or greater) installed it won't work.
</body></html>
"""
#----------------------------------------------------------------------
if __name__ == '__main__':
import sys,os
import run
run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])

View File

@@ -2,10 +2,6 @@
#
# o Updated for wx namespace
#
# 11/28/2003 - Jeff Grimmett (grimmtooth@softhome.net)
#
# o iewin.py is missing
#
import wx

View File

@@ -39,6 +39,9 @@ _treeList = [
'Cursor',
'PyPlot',
'ImageAlpha',
'ActiveX_FlashWindow',
'ActiveX_IEHtmlWindow',
'ActiveX_PDFWindow',
]),
# managed windows == things with a (optional) caption you can close
@@ -126,6 +129,9 @@ _treeList = [
# controls coming from other libraries
('More Windows/Controls', [
'ActiveX_FlashWindow',
'ActiveX_IEHtmlWindow',
'ActiveX_PDFWindow',
#'RightTextCtrl', deprecated as we have wxTE_RIGHT now.
'Calendar',
'CalendarCtrl',
@@ -137,7 +143,7 @@ _treeList = [
'FloatBar',
'FloatCanvas',
'HtmlWindow',
'IEHtmlWin',
##'IEHtmlWin',
'IntCtrl',
'MVCTree',
'MaskedEditControls',
@@ -219,7 +225,7 @@ _treeList = [
# need libs not coming with the demo
('Objects using an external library', [
'ActiveXWrapper_Acrobat',
##'ActiveXWrapper_Acrobat',
##'ActiveXWrapper_IE', # currently has tstate problems...
'GLCanvas',
#'PlotCanvas', # deprecated, use PyPlot

Binary file not shown.