wx播放flash



# -*- 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, parent, -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, proportion=1, flag=wx.EXPAND|wx.ALL, border=5)

        btn = wx.Button(self, wx.NewId(), "打开网络文件")
        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):
        # 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()

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值