比这篇新的文章: template meta test
比这篇旧的文章: P1150.cpp

一个用wxPython实现有FLASH播放器(转贴)

语言: Python, 标签: 无  2008/08/23发布 2个月前更新
作者: 石头, 点击273次, 评论(0), 收藏者(0)

开关行号, 全选(Ctrl+C复制) | 一键复制:HTML, BBCode(Discuz!) , 源代码 | 查看:裸代码, 全屏
背景
主题: 字体:
Python语言: 一个用wxPython实现有FLASH播放器(转贴)
01 #-*- coding: cp936 -*-
02 import   wx
03
04 if wx.Platform == '__WXMSW__':
05        from wx.lib.flashwin import FlashWindow
06
07
08 class MyPanel(wx.Panel):
09        def __init__(self, parent, id):
10               wx.Panel.__init__(self, parent, -1)
11               self.pdf = None
12
13               sizer = wx.BoxSizer(wx.VERTICAL)
14               btnSizer = wx.BoxSizer(wx.HORIZONTAL)
15               self.flash = FlashWindow(self, style=wx.SUNKEN_BORDER)
16               sizer.Add(self.flash, proportion=1, flag=wx.EXPAND)
17               btn = wx.Button(self, wx.NewId(), "打开本地文件")
18               self.Bind(wx.EVT_BUTTON, self.OnOpenFileButton, btn)
19               btnSizer.Add(btn, proportion=1, flag=wx.EXPAND|wx.ALL, border=5)
20               btn = wx.Button(self, wx.NewId(), "打开网络文件")
21               self.Bind(wx.EVT_BUTTON, self.OnOpenURLButton, btn)
22               btnSizer.Add(btn, proportion=1, flag=wx.EXPAND|wx.ALL, border=5)
23               btnSizer.Add((50,-1), proportion=2, flag=wx.EXPAND)
24               sizer.Add(btnSizer, proportion=0, flag=wx.EXPAND)
25               self.SetSizer(sizer)
26               self.SetAutoLayout(True)
27        def OnOpenFileButton(self, event):
28               # make sure you have flash files available on drive
29               dlg = wx.FileDialog(self, wildcard="*.swf")
30               if dlg.ShowModal() == wx.ID_OK:
31                      wx.BeginBusyCursor()
32                      self.flash.LoadMovie(0, 'file://' + dlg.GetPath())
33                      wx.EndBusyCursor()
34               dlg.Destroy()
35
36        def OnOpenURLButton(self, event):
37               # you can retrieve flash files from internet too
38               dlg = wx.TextEntryDialog(self, "输入一个SWF的文件地址", "输入地址")
39               if dlg.ShowModal() == wx.ID_OK:
40                      wx.BeginBusyCursor()
41                      # setting the movie property works too
42                      self.flash.movie = dlg.GetValue()
43                      wx.EndBusyCursor()
44               dlg.Destroy()
45
46
47 app = wx.PySimpleApp()
48 # create window/frame, no parent, -1 is default ID, title, size
49 # change size as needed
50 frame = wx.Frame(None, -1, "FLASH播放器0.01", size = (500, 400))
51 # make instance of class, -1 is default ID
52 MyPanel(frame, -1)
53 # show frame
54 frame.Show(True)
55 # start event loop
56 app.MainLoop()
打分:

所有评论,共0条:( 我也来说两句)


发表评论

注册登录后再发表评论