]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/ActiveX_FlashWindow.py
4 if wx
.Platform
== '__WXMSW__':
5 from wx
.lib
.flashwin
import FlashWindow
9 #----------------------------------------------------------------------
11 class TestPanel(wx
.Panel
):
12 def __init__(self
, parent
, log
):
13 wx
.Panel
.__init
__(self
, parent
, -1)
16 sizer
= wx
.BoxSizer(wx
.VERTICAL
)
17 btnSizer
= wx
.BoxSizer(wx
.HORIZONTAL
)
19 self
.flash
= FlashWindow(self
, style
=wx
.SUNKEN_BORDER
)
20 self
.flash
.LoadMovie(0, 'file://' + os
.path
.abspath('data/Asteroid_blaster.swf'))
22 sizer
.Add(self
.flash
, proportion
=1, flag
=wx
.EXPAND
)
24 btn
= wx
.Button(self
, wx
.NewId(), "Open Flash File")
25 self
.Bind(wx
.EVT_BUTTON
, self
.OnOpenFileButton
, btn
)
26 btnSizer
.Add(btn
, proportion
=1, flag
=wx
.EXPAND|wx
.ALL
, border
=5)
28 btn
= wx
.Button(self
, wx
.NewId(), "Open Flash URL")
29 self
.Bind(wx
.EVT_BUTTON
, self
.OnOpenURLButton
, btn
)
30 btnSizer
.Add(btn
, proportion
=1, flag
=wx
.EXPAND|wx
.ALL
, border
=5)
32 btnSizer
.Add((50,-1), proportion
=2, flag
=wx
.EXPAND
)
33 sizer
.Add(btnSizer
, proportion
=0, flag
=wx
.EXPAND
)
36 self
.SetAutoLayout(True)
40 def OnOpenFileButton(self
, event
):
41 dlg
= wx
.FileDialog(self
, wildcard
="*.swf")
43 if dlg
.ShowModal() == wx
.ID_OK
:
45 self
.flash
.LoadMovie(0, 'file://' + dlg
.GetPath())
51 def OnOpenURLButton(self
, event
):
52 dlg
= wx
.TextEntryDialog(self
, "Enter a URL of a .swf file", "Enter URL")
54 if dlg
.ShowModal() == wx
.ID_OK
:
56 # setting the movie property works too
57 self
.flash
.movie
= dlg
.GetValue()
64 #----------------------------------------------------------------------
66 def runTest(frame
, nb
, log
):
67 if wx
.Platform
== '__WXMSW__':
68 win
= TestPanel(nb
, log
)
71 dlg
= wx
.MessageDialog(frame
, 'This demo only works on MSW.',
72 'Sorry', wx
.OK | wx
.ICON_INFORMATION
)
79 <h2>wx.lib.flashwin.FlashWindow</h2>
81 The wx.lib.pdfwin.FlashWindow class is yet another example of using
82 ActiveX controls from wxPython using the new wx.activex module. This
83 allows you to use an ActiveX control as if it is a wx.Window, you can
84 call its methods, set/get properties, and receive events from the
85 ActiveX control in a very intuitive way.
87 <p> Using this class is simpler than ActiveXWrapper, doesn't rely on
88 the win32all extensions, and is more "wx\'ish", meaning that it uses
89 events and etc. as would be expected from any other wx window.
91 <p> This demo embeds the Shockwave Flash control, and lets you play a game.
96 #----------------------------------------------------------------------
100 if __name__
== '__main__':
103 run
.main(['', os
.path
.basename(sys
.argv
[0])] + sys
.argv
[1:])