??
# -*- coding: gbk -*-
import wx
if wx.Platform == '__WXMSW__':
??? from wx.lib.flashwin import FlashWindow
class MyPanel(wx.Panel):
?def __init__(self,parent,id):
??????? wx.Panel.__init__(self,-1)
??????? self.pdf = None
??????? sizer = wx.BoxSizer(wx.VERTICAL)
??????? btnSizer = wx.BoxSizer(wx.HORIZONTAL)
??????? self.flash = FlashWindow(self,style=wx.SUNKEN_BORDER)
??????? sizer.Add(self.flash,proportion=1,flag=wx.EXPAND)
??????? btn = wx.Button(self,wx.NewId(),"打开本地文件")
??????? self.Bind(wx.EVT_BUTTON,self.OnOpenFileButton,btn)
??????? btnSizer.Add(btn,flag=wx.EXPAND|wx.ALL,border=5)
??????? btn = wx.Button(self,"打开网络文件")
??????? self.Bind(wx.EVT_BUTTON,self.OnOpenURLButton,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):
??????? # make sure you have flash files available on drive
??????? 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):
??????? # you can retrieve flash files from internet too
??????? dlg = wx.TextEntryDialog(self,"输入一个SWF的文件地址","输入地址")
??????? if dlg.ShowModal() == wx.ID_OK:
????????? wx.BeginBusyCursor()
????????? # setting the movie property works too
????????? self.flash.movie = dlg.GetValue()
????????? wx.EndBusyCursor()
??????? dlg.Destroy()
app = wx.PySimpleApp() # create window/frame,no parent,-1 is default ID,title,size # change size as needed frame = wx.Frame(None,-1,"FLASH播放器0.01",size = (500,400)) # make instance of class,-1 is default ID MyPanel(frame,-1) # show frame frame.Show(True) # start event loop app.MainLoop()