thread focus question.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mike Zupan

    thread focus question.

    I wrote this simple threading app using pygame. I'm looking to load a
    movie via mplayer in full screen mode and have all my events be sent
    to my python app and not mplayer. When my mouse is over the python app
    it handles the events but when its over the mplayer window it handles
    mplayer only. I'm new to threads so if anyone has a really great
    tutorial let me know. My book didn't go into great detail



    import pygame
    from pygame.locals import *
    import thread
    from time import sleep, time, ctime
    import os
    import sys

    mplayer_loc = '/usr/local/bin/mplayer'
    mplayer_args = ' -vo xv -slave '
    file = '/dump/mp3s/1short.mpeg'

    def loop0():
    print "using mplayer which is at: ", mplayer_loc
    os.system(mplay er_loc + mplayer_args + file)
    while 1:
    for event in pygame.event.ge t():
    if event.type == KEYDOWN:
    print "KeyDown on the MOVIE!",
    event.key

    def main():
    pygame.init()
    window = pygame.display. set_mode((600,4 00))
    pygame.display. set_caption('te sting')
    #pygame.display .toggle_fullscr een()
    print 'starting threads'
    thread.start_ne w_thread(loop0, ())
    while 1:
    for event in pygame.event.ge t():
    if event.type == KEYDOWN:
    print "KeyDown", event.key
    print 'all done at: ', ctime(time())


    if __name__ == '__main__':
    main()
  • Aahz

    #2
    Re: thread focus question.

    In article <9d302332.03091 31238.1f4ee076@ posting.google. com>,
    Mike Zupan <mzupan@meso.co m> wrote:[color=blue]
    >
    >I wrote this simple threading app using pygame. I'm looking to load a
    >movie via mplayer in full screen mode and have all my events be sent
    >to my python app and not mplayer. When my mouse is over the python app
    >it handles the events but when its over the mplayer window it handles
    >mplayer only.[/color]

    It appears that mplayer is a separate process. The only way what you
    want will work would be if you can get mplayer to forward events over a
    socket or something.
    --
    Aahz (aahz@pythoncra ft.com) <*> http://www.pythoncraft.com/

    "It is easier to optimize correct code than to correct optimized code."
    --Bill Harlan

    Comment

    Working...