Patch to exit from window.mainloop()

182 views
Skip to first unread message

Mauricio de Alencar

unread,
May 27, 2011, 3:08:35 PM5/27/11
to glumpy-users
Hello,

I am experimenting with glumpy for displaying electromagnetic FDTD
simulation data and I am missing a way to exit from a
window.mainloop() call.

The solution I found was to add a reference to glutLeaveMainLoop to
the Window class definition. Then it is possible to call
window.leaveloop() from any window event handler to cleanly exit the
program.

==== window.py ====

class Window(event.EventDispatcher, Singleton):

leaveloop = glut.glutLeaveMainLoop

========

Thanks for developing glumpy, displaying data is now much faster than
with matplotlib.

Regards,
Mauricio

Nicolas Rougier

unread,
May 31, 2011, 3:30:21 AM5/31/11
to glumpy-users

Thanks for the patch. I integrated as an "exit" function into window
class.
I also had to test if glutLeaveMainLoop exists since it depends on
glut implementation.

Nicolas

Pierre Villeneuve

unread,
Oct 23, 2011, 1:09:32 PM10/23/11
to glumpy...@googlegroups.com
It looks like my GLUT implementation does not support the function glutLeaveMainLoop. :(  I would like to use glumpy along with ipython as part of my interactive data processing.  Right now I do not see how to get around the fact that when I close a glumpy figure window, it kills the entire Python process.  There must be another more practical manner to exit the glumpy main event loop??  I know that with pyglet it was possible to call something like ....app.exit(), and it would exit right back to where it started.  Is there not some way to achieve this type of functionality with glumpy?   

Or maybe there is something and I just have not figured it out yet.  Anybody have ideas?  

Keep up the great work!  Glumpy is awesome!!

Nicolas Rougier

unread,
Oct 24, 2011, 6:53:08 AM10/24/11
to glumpy...@googlegroups.com
What is your glut implementation ? If you're using free glut, I'm
pretty sure there is a glutLeaveMainLoop.

As for exiting glumly properly, you have to put a handler on the close
event. Have a look at example in ipython:

https://github.com/ipython/ipython/blob/master/docs/examples/lib/gui-glut.py


Nicolas

Pierre Villeneuve

unread,
Oct 24, 2011, 8:38:55 AM10/24/11
to glumpy...@googlegroups.com
I'm not sure what my glut is.  I installed pyopengl and assumed that took care of everything?

Pierre
--
pierre.v...@gmail.com

Nicolas Rougier

unread,
Oct 24, 2011, 8:46:55 AM10/24/11
to glumpy-users

Not exactly because pyopengl will wrap the existing glut library.
What is your system ? (linux, win, osx ?)

Nicolas



On Oct 24, 2:38 pm, Pierre Villeneuve <pierre.villene...@gmail.com>
wrote:
> I'm not sure what my glut is.  I installed pyopengl and assumed that took
> care of everything?
>
> Pierre
> --
> pierre.villene...@gmail.com
>
> On Mon, Oct 24, 2011 at 3:53 AM, Nicolas Rougier
> <nicolas.roug...@gmail.com>wrote:
>
>
>
>
>
>
>
> > What is your glut implementation ? If you're using free glut, I'm
> > pretty sure there is a glutLeaveMainLoop.
>
> > As for exiting glumly properly, you have to put a handler on the close
> > event. Have a look at example in ipython:
>
> >https://github.com/ipython/ipython/blob/master/docs/examples/lib/gui-...

Pierre Villeneuve

unread,
Oct 24, 2011, 8:56:53 AM10/24/11
to glumpy...@googlegroups.com
Ahh I see.   My system is Windows 7 x64.  I am running Python 2.7 x64.

I just checked out the freeglut web site and have downloaded the MSVC x32 version of the their precompiled library.  I have to go to work right now, so I can't really test this out at the moment.  But I suspect that I will really need a x64 compiled version.  The maintainer of the freeglut site indicates an experimental x64 version available upon request.  I will ask for that too and see how it goes.

BTW, how do I figure out the particulars of my glut implementation?

Pierre Villeneuve

unread,
Oct 24, 2011, 10:27:13 AM10/24/11
to glumpy...@googlegroups.com
Ok, I suspect now my problem is related to the fact that I am doing everything with 64-bit stuff.  I downloaded freeglut and compiled with with my VS2008 and generated a 64-bit DLL.  I copied this into the PyOpenGL folder named DLLs.  Now the example code from the above referenced IPython example test case works fine.  But I still cannot call glut.glutLeaveMainLoop without getting the error "NullFunctionError: Attempt to call an undefined function glutLeaveMainLoop, check for bool(glutLeaveMainLoop) before calling"

Any ideas?

Pierre Villeneuve

unread,
Oct 24, 2011, 10:59:12 AM10/24/11
to glumpy...@googlegroups.com
I may have solved my problem.

Overview: I am running Python 2.7.1 x64 on Windows 7 x64.  I downloaded PyOpenGL from Chris Gohlke's very convenient web site: http://www.lfd.uci.edu/~gohlke/pythonlibs/ , specifically, I used "PyOpenGL-3.0.1.win-amd64-py2.7.‌exe".

Here are the steps I went through to have something working:
1. I downloaded the freeglut source code from: http://freeglut.sourceforge.net/
2. This package came with a MSVC2008 solution.  I modified it (very simple) to compile a x64 Release version.
3. Next I looked in my PyOpenGL site-packages folder and clicked into the DLLS subfolder.  I renamed the file "glut32.dll" to "glut32.dll.BAK"  and renamed "freeglut.dll" to "freeglut.dll.BAK".
4. Next I copied my newly compiled files "freeglut.dll" and "freeglut.lib" from the above-mentioned Release folder to the PyOpenGL DLLS folder.

This worked for me this morning and I hope maybe this info is helpful to others down the road.

Reply all
Reply to author
Forward
0 new messages