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

Re: [pygame] pygame+threading+windows




On Aug 2, 2006, at 6:57 AM, Lars Friedrich wrote:

Hello,

Am Montag, den 31.07.2006, 10:44 -0700 schrieb Lenard Lindstrom:
The event loop must be in the same thread as that which initializes
pygame and brings up the main window. Move everything into the run
method and it works.

Am Montag, den 31.07.2006, 09:40 -0700 schrieb Bob Ippolito:
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.

Thank you, Bob and Lenard, now it works. I put everything to the run () method.


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.

This implies, that all user interfacing is done in the main thread.
What is the usual way to deal with this in an object oriented approach?


My plan was to have several classes that inherit from "Thread" and are
each responsible for a certain part of the GUI. This way I have the
possibility to easily switch one part of my GUI on or off by
instantiating resp. deleting an object of the responsible class.
Learning that one cannot delete Threads and that all GUI-event- handling
should be done in the main Thread disappointed me little. What is the
usual structure, if I want to have a highly configurable framework,
with different GUI-Windows, not present in every application?

Why do you think you need threads? Nothing you've said implies a need or want for threads at all.


-bob