Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #25730 > unrolled thread
| Started by | Dieter Maurer <dieter@handshake.de> |
|---|---|
| First post | 2012-07-21 10:32 +0200 |
| Last post | 2012-07-21 10:32 +0200 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: A thread import problem Dieter Maurer <dieter@handshake.de> - 2012-07-21 10:32 +0200
| From | Dieter Maurer <dieter@handshake.de> |
|---|---|
| Date | 2012-07-21 10:32 +0200 |
| Subject | Re: A thread import problem |
| Message-ID | <mailman.2369.1342859551.4697.python-list@python.org> |
Bruce Sherwood <bruce.sherwood@gmail.com> writes: > ... > from visual import box, rate > b = box() > while True: > rate(100) # no more than 100 iterations per second > b.pos.x += .01 > > This works because a GUI environment is invoked by the visual module > in a secondary thread (written mainly in C++, connected to Python by > Boost). The OpenGL rendering of the box in its current position is > driven by a 30-millisecond timer. This works fine with any environment > other than Mac Cocoa. > > However, the Mac Cocoa GUI environment and interact loop are required > to be the primary thread, so the challenge is to have the visual > module set up the Cocoa environment, with the user's program running > in a secondary thread. Any ideas? The usual approach to this situation is to invoke the user code via a callback from the UI main loop or invoke it explicitely after the UI system has been set up immediately before its main loop is called. Might look somehow like this: main thread: from thread import start_new_thread from visual import setup_gui, start_main_loop setup_gui() # sets up the GUI subsystem start_new_thread(lambda: __import__(<your module>), ()) start_main_loop()
Back to top | Article view | comp.lang.python
csiph-web