Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: A thread import problem

Reply
Thread Tools

Re: A thread import problem

 
 
Dieter Maurer
Guest
Posts: n/a
 
      07-21-2012
Bruce Sherwood <(E-Mail Removed)> 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()




 
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
Re: A thread import problem Dieter Maurer Python 0 07-19-2012 08:31 AM
Re: A thread import problem Dennis Lee Bieber Python 0 07-19-2012 12:47 AM
A thread import problem Bruce Sherwood Python 0 07-18-2012 11:03 PM
problem(s) with import from parent dir: "from ../brave.py import sir_robin" per9000 Python 7 02-27-2006 06:36 PM
Problem with import "from omniORB import CORBA, PortableServer" Stefan Seefeld Python 3 04-11-2005 08:54 PM



Advertisments