Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > thread focus question.

Reply
Thread Tools

thread focus question.

 
 
Mike Zupan
Guest
Posts: n/a
 
      09-13-2003
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()
 
Reply With Quote
 
 
 
 
Aahz
Guest
Posts: n/a
 
      09-13-2003
In article <(E-Mail Removed) >,
Mike Zupan <(E-Mail Removed)> 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 ((E-Mail Removed)) <*> http://www.pythoncraft.com/

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

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
this.window.focus() vs. window.focus() vs. this.focus() Roger Javascript 3 03-08-2007 08:53 PM
Why "Focus and Recompose" causes back-focus issues Carl Miller Digital Photography 7 03-10-2005 12:14 PM
Fuji EXIF: Focus warning: "Out of focus" Hasan Diwan Digital Photography 3 12-26-2004 04:13 AM
Pan Focus vs Auto Focus JethroUK© Digital Photography 2 08-11-2004 06:26 PM
any manual focus cameras easy to focus? Catherine Jo Morgan Digital Photography 6 11-05-2003 06:36 PM



Advertisments