pythonCOM with Flash

Bradley Schatz bradley at greystate.com
Thu Jun 12 02:08:17 CEST 2003


Hi,

I am attempting to use Flash as a UI for a python program. I have
successfully prototyped this using VB/Flash, and am not trying to convert it
over to work with python.

My problem is this, when I run the following code (attached below) nothing
happens.

I assume that the Flash activex component needs to be placed in some
container to be seen, as I am not seeing any window come up when I run this.

Could anyone suggest how to embed this into a container?

Many thanks,

Bradley



# Flashevents - test flash/python interop
from win32com.client import DispatchWithEvents, Dispatch
import msvcrt, pythoncom
import time, sys
import types

import threading
stopEvent = threading.Event()

def TestFlash():
    class FlashEvents:
 def OnFSCommand(self, command, args):
  print "FSCommend" , command
 def OnProgress(self, percentDone):
  print "PercentDone", percentDone
 def OnReadyStateChange(self, newState):
  print "State", newState

    e = DispatchWithEvents("ShockwaveFlash.ShockwaveFlash", FlashEvents)
    e.seen_events = {}
    e.LoadMovie(0,
"http://atomfilms.shockwave.com/afassets/flash/hump_starwars.swf")
    e.Play()
    if not _WaitForFinish(e, 10000):
        e.Quit()



def _WaitForFinish(ob, timeout):
    end = time.time() + timeout
    while 1:
        if msvcrt.kbhit():
            msvcrt.getch()
            break
        pythoncom.PumpWaitingMessages()
        stopEvent.wait(.2)
        if stopEvent.isSet():
            stopEvent.clear()
            break

    return 1


def test():
    import sys
    TestFlash()

if __name__=='__main__':
    test()







More information about the Python-list mailing list