On Mon, May 11, 2009 at 2:52 PM, Matt Jones <[email protected]> wrote:

>
> Hey Tristam -
>
> Thanks for the quick response!  I have a couple questions inline:
>
> On May 11, 6:31 am, Tristam MacDonald <[email protected]> wrote:
> > On Mon, May 11, 2009 at 12:06 AM, Matt Jones <[email protected]>
> wrote:
> >
> > > So I've come across what seems like a strange problem with
> > > interactions between Pyglet and wxPython on OS X.  My apologies if
> > > this isn't the right forum for this - feel free to direct me elsewhere
> > > if it's not...
> >
> > > I've got a very simple program where a thread creates a wx App and
> > > Frame.  This thread is started from the main thread.  When importing
> > > (but not even using) pyglet.gl.gl on OS X, the event loop seems to
> > > hang - I just get a spinning beach ball when mousing over the app.
> >
> > > When not importing pyglet.gl.gl, or when launching the App / Frame
> > > from the main thread instead of the second Thread, everything works
> > > fine.
> >
> > It is typically not a good idea to try to gather events from the OS or
> > perform OpenGL rendering from a secondary thread (particularly on OS X).
> If
> > you do need to do this, make very sure that one and only one thread is
> > interacting with the windowing and event handling code,
>
> This is interesting. What do I do if I need an event loop for a pyglet
> OpenGL window and another one for other UI elements (e.g.  wx
> windows)?  It seems that pyglet quickly breaks when it's not on the
> main thread, and wx does as well - how can I run these two together?


I would recommend dumping the pyglet window entirely, and just using a
wxWindow with a wxGL context to render.

However, if you really want the separate windows, you can try just getting
rid of the pyglet event loop, and manually calling window.dispatch_events()
and window.flip() instead.

 > Also worth noting is that due to the global interpreter lock, using
> multiple
> > threads in python has no real performance benefit, so only use multiple
> > threads if you need preemption.
>
> Yeah, I'm not trying to do multiprocessing or anything - just have an
> event loop for the main UI and another one (as required) for the
> OpenGL window in pyglet.  How can I do this without crashing?  FWIW,
> things work fine with a secondary thread for the wx window on Ubuntu
> and Windows.


Mac is special - and not always in a good way. I think it is at least partly
because the entire UI is drawn using OpenGL, but whatever the reason, native
UI elements (and by extension wxWidgets) are a bit tricky to manage on a
separate thread from your OpenGL rendering.

-- 
Tristam MacDonald
http://swiftcoder.wordpress.com/

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pyglet-users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/pyglet-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to