| | |
write a flash player by python
Thread Solved |
I am not sure if there is a Python module out there that includes the .swf file format. However you can press your webbrowser into service ...
The sample Chicken.swf file is in the attached zip.
python Syntax (Toggle Plain Text)
import webbrowser # html code to embed a .swf flash file player str1 = """ <html> <head> <title>Embedded SWF Player</title> </head> <body onLoad="resizeTo(560, 500);"> <!-- you can put your own .swf movie file here --> <embed src = "Chickens.swf" width="500" height="350" hidden=false autostart=true loop=1> </body> </html> """ # write the html file to the working folder fout = open("EmbeddedFlash.htm", "w") fout.write(str1) fout.close() # now open your web browser to run the file webbrowser.open("EmbeddedFlash.htm")
May 'the Google' be with you!
•
•
Join Date: Dec 2006
Posts: 4
Reputation:
Solved Threads: 0
hi vegaseat ,
thanks,it works,but I want that in my UI,
Do you know how to use the webbrowser module into a canvas.
any way thank you so much!
thanks,it works,but I want that in my UI,
Do you know how to use the webbrowser module into a canvas.
any way thank you so much!
Actually the Python25 version of wxPython has a flash player component. Here is the demo they give:
Python Syntax (Toggle Plain Text)
import os import wx if wx.Platform == '__WXMSW__': from wx.lib.flashwin import FlashWindow from Main import opj #---------------------------------------------------------------------- class TestPanel(wx.Panel): def __init__(self, parent, log): 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) self.flash.LoadMovie(0, 'file://' + os.path.abspath('data/Asteroid_blaster.swf')) sizer.Add(self.flash, proportion=1, flag=wx.EXPAND) btn = wx.Button(self, wx.NewId(), "Open Flash File") 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(), "Open Flash URL") 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): 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): dlg = wx.TextEntryDialog(self, "Enter a URL of a .swf file", "Enter URL") if dlg.ShowModal() == wx.ID_OK: wx.BeginBusyCursor() # setting the movie property works too self.flash.movie = dlg.GetValue() wx.EndBusyCursor() dlg.Destroy() #---------------------------------------------------------------------- def runTest(frame, nb, log): if wx.Platform == '__WXMSW__': win = TestPanel(nb, log) return win else: from Main import MessagePanel win = MessagePanel(nb, 'This demo only works on Microsoft Windows.', 'Sorry', wx.ICON_WARNING) return win overview = """\ <html><body> <h2>wx.lib.flashwin.FlashWindow</h2> The wx.lib.pdfwin.FlashWindow class is yet another example of using ActiveX controls from wxPython using the new wx.activex module. This allows you to use an ActiveX control as if it is a wx.Window, you can call its methods, set/get properties, and receive events from the ActiveX control in a very intuitive way. <p> Using this class is simpler than ActiveXWrapper, doesn't rely on the win32all extensions, and is more "wx\'ish", meaning that it uses events and etc. as would be expected from any other wx window. <p> This demo embeds the Shockwave Flash control, and lets you play a game. </body></html> """ #---------------------------------------------------------------------- if __name__ == '__main__': import sys,os import run run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])
drink her pretty
I think wxPython demos were written by my C++ professor or his father. He always uses the C++ trick of putting in obscure header files, to make student's life harder!
I have simplified some code that works without those extra imports at:
http://www.daniweb.com/code/snippet615.html
I have simplified some code that works without those extra imports at:
http://www.daniweb.com/code/snippet615.html
![]() |
Similar Threads
- Flash Player stop working since Ad-aware (Web Browsers)
- Flash Player stop working and won't reinstall (Windows NT / 2000 / XP)
Other Threads in the Python Forum
- Previous Thread: Extending A Class
- Next Thread: unicode and pythonw.exe
| Thread Tools | Search this Thread |
abrupt alarm ansi anti approximation assignment avogadro backend beginner binary bluetooth calculator character cmd code customdialog cx-freeze data decimals dictionaries dictionary directory dynamic error examples exe file float format function gnu graphics gui halp heads homework http ideas import input java launcher leftmouse line linux list lists loop module mouse number numbers output parsing path pointer port prime programming progressbar projects push py2exe pygame pyglet pyqt python random recursion schedule screensaverloopinactive script scrolledtext sqlite statistics string strings sudokusolver sum table terminal text thread threading time tlapse tricks tuple tutorial twoup ubuntu unicode urllib urllib2 variable ventrilo wikipedia write wxpython xlib






