Thanks for your reply Mike, I'm on Ubuntu linux. The reason I don't want to start the pyglet event loop is because I want to be able to interact with the program through the interpreter while it is running, but interpreter input is blocked while the event loop is running.
Is it possible to handle the events triggered by draw() et al. just once after calling them and then returning to the interpreter again? Should I just start the normal event loop for one frame, or will this result in a large overhead for starting/stopping? Also, any idea why the call to pg.app.run wont work when I do it in the interpreter as opposed to in the __main__ block? On Jul 18, 2:44 pm, Mike Redhorse <[email protected]> wrote: > The first example won't work because the draw(), clear(), etc > functions, are triggering events. With no running event loop, nothing > will happen. I don't understand why you're not calling app.run() > though. A running event loop shouldn't hurt you at all, surely? > > Also, what OS are you on? Event loops differ based on OS. > > You could also make your own event loop, and ignore any events you > aren't looking for. > > On Jul 18, 1:17 pm, Taco <[email protected]> wrote: > > > > > > > > > Hi there, > > > I've been playing around with pyglet in order to get some offscreen > > rendering to work. I want to render simple shapes and convert them to > > numpy arrays. Following the advice given > > inhttp://groups.google.com/group/pyglet-users/browse_thread/thread/71cb... > > , I created an invisible window and didn't call app.run(). For now, > > I'm just rendering on screen. My code looks something like this: > > > window = pg.window.Window(visible = False) > > window.set_size(10,10) > > window.clear() > > drawTriangle( ) > > window.flip() > > x = screenAsArray() # Does a screencapture and converts to numpy array > > > This doesn't work, so I thought that maybe I could just start and stop > > the event loop for one frame whenever needed. So I tried something > > like this: > > > if __name__ == "__main__": > > > window = pg.window.Window()#visible = False) > > window.set_size(10,10) > > > @window.event > > def on_draw(): > > window.clear() > > drawTriangle() > > x = screenAsArray() > > pg.app.exit() > > > pg.app.run() > > > This works, but ONLY if I make the pg.app.run call where it is in the > > above example. When I place it in another function or enter it in the > > interpreter, it doesn't work. It does work when I leave the run call > > where it is, so that it renders one frame, and then call pg.app.run > > again in the interpreter later.. Does anyone know what's going on > > here? > > > I would preferably get the first method to work. It seems like app.run > > does some initialization work that I'm not doing in the first code > > snippet above. > > > Any help is appreciated. -- 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.
