]> git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/ActiveX_FlashWindow.py
updated to wx namespace by Peter Damoc
[wxWidgets.git] / wxPython / demo / ActiveX_FlashWindow.py
1 import os
2 import wx
3
4 if wx.Platform == '__WXMSW__':
5 from wx.lib.flashwin import FlashWindow
6
7 from Main import opj
8
9 #----------------------------------------------------------------------
10
11 class TestPanel(wx.Panel):
12 def __init__(self, parent, log):
13 wx.Panel.__init__(self, parent, -1)
14 self.pdf = None
15
16 sizer = wx.BoxSizer(wx.VERTICAL)
17 btnSizer = wx.BoxSizer(wx.HORIZONTAL)
18
19 self.flash = FlashWindow(self, style=wx.SUNKEN_BORDER)
20 self.flash.LoadMovie(0, 'file://' + os.path.abspath('data/Asteroid_blaster.swf'))
21
22 sizer.Add(self.flash, proportion=1, flag=wx.EXPAND)
23
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)
27
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)
31
32 btnSizer.Add((50,-1), proportion=2, flag=wx.EXPAND)
33 sizer.Add(btnSizer, proportion=0, flag=wx.EXPAND)
34
35 self.SetSizer(sizer)
36 self.SetAutoLayout(True)
37
38
39
40 def OnOpenFileButton(self, event):
41 dlg = wx.FileDialog(self, wildcard="*.swf")
42
43 if dlg.ShowModal() == wx.ID_OK:
44 wx.BeginBusyCursor()
45 self.flash.LoadMovie(0, 'file://' + dlg.GetPath())
46 wx.EndBusyCursor()
47
48 dlg.Destroy()
49
50
51 def OnOpenURLButton(self, event):
52 dlg = wx.TextEntryDialog(self, "Enter a URL of a .swf file", "Enter URL")
53
54 if dlg.ShowModal() == wx.ID_OK:
55 wx.BeginBusyCursor()
56 # setting the movie property works too
57 self.flash.movie = dlg.GetValue()
58 wx.EndBusyCursor()
59
60 dlg.Destroy()
61
62
63
64 #----------------------------------------------------------------------
65
66 def runTest(frame, nb, log):
67 if wx.Platform == '__WXMSW__':
68 win = TestPanel(nb, log)
69 return win
70 else:
71 dlg = wx.MessageDialog(frame, 'This demo only works on MSW.',
72 'Sorry', wx.OK | wx.ICON_INFORMATION)
73 dlg.ShowModal()
74 dlg.Destroy()
75
76
77 overview = """\
78 <html><body>
79 <h2>wx.lib.flashwin.FlashWindow</h2>
80
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.
86
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.
90
91 <p> This demo embeds the Shockwave Flash control, and lets you play a game.
92
93 </body></html>
94 """
95
96 #----------------------------------------------------------------------
97
98
99
100 if __name__ == '__main__':
101 import sys,os
102 import run
103 run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])
104
105