[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[pygame] pygame+threading+windows
Hello,
I am trying to use pygame to display some camera images on the screen.
It is really fine, the speed is very satisfying!
Now the program has to something besides displaying images, so I want to
put the whole pygame-thing into a Thread. Please see the attached file
for my first trial. On my Linux-machine this runs fine.
The problem is, when I run the program in Windows (which I have to do,
because the hardware I have to talk to is not available in Linux), the
pygame-window hangs. No "event" is printed to std. I have to kill the
window explicitely with the windows-end-now dialogue. What can I do
about it? I suspect this to be a "threading"-issue not a "pygame"-issue,
but maybe someone here had the same problem, and maybe also a solution?
Thank you for every comment
Lars
--
Dipl.-Ing. Lars Friedrich
Optical Measurement Technology
Department of Microsystems Engineering -- IMTEK
University of Freiburg
Georges-KÃhler-Allee 102
D-79110 Freiburg
Germany
phone: +49-761-203-7531
fax: +49-761-203-7537
room: 01 088
email: lfriedri@xxxxxxxx
import sys, pygame
from threading import Thread
class Window(Thread):
def __init__(self):
Thread.__init__(self)
pygame.init()
size = width, height = 320, 240
screen = pygame.display.set_mode(size)
def run(self):
while 1:
for event in pygame.event.get():
print "event"
if event.type == pygame.QUIT:
sys.exit()
myWindow = Window()
myWindow.start()
myWindow.join()