Thanks for your help on this matter... > > Talking to myself here, but for the benefit of others who might > > wonder: it appears from googling that cocoa GUIs have to be run from > > thread-0; not so for carbon GUIs. This seems to be an OS/cocoa-level > > limitation. > > If memory serves, the restriction isn't that everything has to run from > thread zero, just that it all has to run from the same thread where the > NSApplication is spawned.
That's what I thought, but a little googling made me wonder if things were otherwise. This very old discussion, for example: http://www.cocoabuilder.com/archive/cocoa/112663-nsapplication-run-called-from-not-the-default-thread.html And, for example, if it were true that NSApplication could be started in any thread and things would work fine, you would expect the following to work, which it doesn't really. (NSApplication gets started as part of the "import pyglet.app" statement...) def start_pyglet(): import pyglet.app pyglet.app.event_loop.run() import threading t = threading.Thread(target=start_pyglet) t.setDaemon(True) t.start() > > My initial email still reports a relevant bug in the cocoa backend in > > that "import pyglet.app" starts some GUI code running, whereas for > > other backends nothing happens until the event loop is explicitly > > started... > > I don't quite understand what you mean here, and I think it might be related > to a misunderstanding about how Cocoa operates. > > You want to be able to create a pyglet window before starting the event > loop, right? > > Well a window is a GUI resource, so the GUI framework must be initialised by > this time (i.e. as soon as you import pyglet). And initialising AppKit > involves creating the NSApplication instance, which will cause the dock icon > and menu bars to be created. Yes, right. But I thought that a fairly clear part of the pyglet "contract" in previous versions (and with other backends) was that no GUI initialization happens implicitly if the "shadow_window" option is turned off. So you could import pyglet.app and do various things before starting up all the GUI machinery. But with the cocoa backend, even with the "shadow_window" option turned off, NSApp.run() gets started implicitly by importing "pyglet.app". I'm not sure it's a "bug" per se, but it's definitely not a "feature". Zach -- 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.
