This is the experimental pyglet event loop integration.
It requires pyglet.
Added code for the pyglet interactive session
Missing files added
Missing files added (again). Need to practice with git...
I'm not experienced with pyglet, but this looks fine to me. You may want to fix the one remaining 'wxPython' hanging around in inputhook, from the copy/paste from the wx section.
This looks good overall, but I can't seem to close the window of the demo applet when I run it. Do you know why? Ideally, we'd offer users the ability to run a script, close all of its windows and then run it again as many times as they want, without ever losing the interactive shell. That works right now for the wx/gtk/qt event loops, so let's try to get the two GL ones in similar shape, if possible.
Also, fixing the wx references Min pointed out would be good.
Finally, if you can figure out what's going on with the window closing, we only have one more issue to sort out: any option supported by the gui magic should also be supported by the --gui command-line flag, so users can start ipython in gui mode if they want to from the beginning.
The code that defines these options is here:
so it should gain a 'pyglet' option. Once that is working, it should be 100% equivalent to type at the system shell:
ipython --gui pyglet
or at the IPython prompt:
Thanks a lot for the good work! I realize these GL event loops are proving a little hard to get right, but hopefully we can finish the process and merge both of your pull requests. We just want to make sure they work reliably and correctly in the intended manner. If ultimately some of it can't be made to work that's OK, but then we'd want to add code that informs the user in a visible manner what the limitations are of a given GL option.
Adding the following lines to docs/examples/lib/gui-pyglet.py:
should fix the window closing issue.
Thanks for the tip! It almost works, as in that now I can close the window, but then a nasty traceback goes to the terminal with:
Traceback (most recent call last):
File "_ctypes/callbacks.c", line 295, in 'calling callback function'
File "/home/fperez/usr/lib/python2.6/site-packages/IPython/lib/inputhookpyglet.py", line 65, in inputhook_pyglet
File "/usr/lib/pymodules/python2.6/pyglet/window/xlib/__init__.py", line 797, in flip
self._config._fbconfig, self._window, None)
AttributeError: 'NoneType' object has no attribute '_fbconfig'
Any idea what to do about that?
A similar traceback has been reported here:
Apparently it does not occur on Windows, and I can't reproduce it either on my mac.
Thanks for the info @jalalhugo, it looks to be a pyglet bug then. If anyone knows how to work around it, that would be great; otherwise we'll just have to live with it in linux (it doesn't actually crash ipython, it just dumps a bunch of info to the screen).
With that info, @rougier, I think we can proceed as follows:
Let me know if you need any help. It seems we'll be able to merge this one pretty soon then :)
Added the close handler
Removed wx reference in comment
Added the pyglet in gui option
Great, thanks! If you look, I added one more commit with a few minor tweaks: fe30ce1. This way we silence that annoying traceback on linux, without slowing down other platforms with a try/except.
I also changed the definition of stdin_ready() to make it platform dependent, that way the platform check happens only once when it's loaded instead of on every call.
Thanks again for the contribution!