Re: [PyOpenGL-Users] Beginners question -- How to end OpenGLContext examples
Brought to you by:
mcfletch
From: Mike C. F. <mcf...@ro...> - 2003-02-14 21:06:59
|
Well, clicking in the x in the upper right corner should work fine. With wxPython you can also use the standard (on Windows) Alt+F4 "close application" key-combination. OpenGLContext doesn't do anything special with regard to exiting, as when embedded it's hard to come up with a "nice" way to kill the application. Here's a simple example that works with the testingcontexts you're likely using: def OnQuit( self, event ): print 'quitting' self.GetParent().Close() That closes the top-level frame, which is the "preferred" way to exit wxPython apps. Obviously, that wouldn't work with a context that's embedded inside a panel or other control. There are functions in wxPython to kill the app regardless, but I'd rather not build those into something that's supposed to be flexible in where it's deployed. Note, however, that the way you were trying _should_ work (and does on my machine) i.e. : def OnQuit( self, event ): print 'quitting' import sys sys.exit(0) causes the context to exit on my machine with the wxPython context. It does, however, cause a debug warning from wxPython complaining that it couldn't de-register the context's GLCanvas class because there's still an open instance of the window. That's with Python 2.2.2 and wxPython 2.4.0.2u on Win2k. HTH, Mike Lothar Birk wrote: >Hi, > >is there a decent way to end the examples in OpenGLContext/tests, like >pressing 'Esc' or 'q'? >So far I only managed to kill python :-( > >I tried to add in OnInit of the TexContext class > >self.addEventHandler( 'keypress', name = 'q', \ > function = self.OnQuit ) > >and defined in the TestContext class: > >def OnQuit(self, event): # does not work so far > import sys > sys.exit() > >However, this does not work. The preferred context startet >is a wxGLCanvas. Any help appreciated > >Lothar > > > > > >------------------------------------------------------- >This SF.NET email is sponsored by: FREE SSL Guide from Thawte >are you planning your Web Server Security? Click here to get a FREE >Thawte SSL guide and find the answers to all your SSL security issues. >http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0026en >_______________________________________________ >PyOpenGL Homepage >http://pyopengl.sourceforge.net >_______________________________________________ >PyOpenGL-Users mailing list >PyO...@li... >https://lists.sourceforge.net/lists/listinfo/pyopengl-users > > > -- _______________________________________ Mike C. Fletcher Designer, VR Plumber, Coder http://members.rogers.com/mcfletch/ |