[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] pygame+threading+windows




On Jul 31, 2006, at 8:37 AM, Lars Friedrich wrote:

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?

In general you must use pygame on the main thread. The same is true with any cross-platform GUI. You should start other threads for the other tasks your application is doing.


In this specific case, I think Windows requires you to use the same thread that was used to initialize pygame. __init__ and run() are not executed from the same thread. In the general platform case (OS X) you must use the main thread for both, but with Windows and X11 you should be able to get away with using any thread as long as it's the same for both.

-bob