thread focus question.

Discussion in 'Python' started by Mike Zupan, Sep 13, 2003.

  1. Mike Zupan

    Mike Zupan Guest

    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(mplayer_loc + mplayer_args + file)
    while 1:
    for event in pygame.event.get():
    if event.type == KEYDOWN:
    print "KeyDown on the MOVIE!",
    event.key

    def main():
    pygame.init()
    window = pygame.display.set_mode((600,400))
    pygame.display.set_caption('testing')
    #pygame.display.toggle_fullscreen()
    print 'starting threads'
    thread.start_new_thread(loop0, ())
    while 1:
    for event in pygame.event.get():
    if event.type == KEYDOWN:
    print "KeyDown", event.key
    print 'all done at: ', ctime(time())


    if __name__ == '__main__':
    main()
     
    Mike Zupan, Sep 13, 2003
    #1
    1. Advertising

  2. Mike Zupan

    Aahz Guest

    In article <>,
    Mike Zupan <> wrote:
    >
    >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.


    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 () <*> http://www.pythoncraft.com/

    "It is easier to optimize correct code than to correct optimized code."
    --Bill Harlan
     
    Aahz, Sep 13, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jason
    Replies:
    4
    Views:
    1,686
    Jason
    May 7, 2007
  2. Replies:
    2
    Views:
    360
    Thomas 'PointedEars' Lahn
    Jun 6, 2005
  3. Roger
    Replies:
    3
    Views:
    380
  4. Jeff

    manual focus vs. focus()

    Jeff, May 20, 2007, in forum: Javascript
    Replies:
    4
    Views:
    198
  5. Spizzat2
    Replies:
    2
    Views:
    198
    Spizzat2
    Jan 9, 2008
Loading...

Share This Page