Pyglet #743

Merged
merged 6 commits into from Sep 13, 2011

Projects

None yet

4 participants

@rougier
rougier commented Aug 29, 2011

This is the experimental pyglet event loop integration.
It requires pyglet.

@minrk
Member
minrk commented Sep 6, 2011

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.

@fperez
Member
fperez commented Sep 12, 2011

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:
https://github.com/ipython/ipython/blob/master/IPython/frontend/terminal/ipapp.py#L232

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:

%gui pyglet

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.

@jalalhugo

Adding the following lines to docs/examples/lib/gui-pyglet.py:

@window.event
def on_close():
window.close()

should fix the window closing issue.

@fperez
Member
fperez commented Sep 12, 2011

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
    window.flip()
  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?

@jalalhugo

A similar traceback has been reported here:

http://groups.google.com/group/pyglet-users/browse_thread/thread/47c1aab9aa4a3d23/c22f9e819826799e?#c22f9e819826799e

Apparently it does not occur on Windows, and I can't reproduce it either on my mac.

@fperez
Member
fperez commented Sep 13, 2011

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:

  • go ahead and incorporate the suggestion above into the example
  • add support for --gui pyglet at the command line as indicated above.

Let me know if you need any help. It seems we'll be able to merge this one pretty soon then :)

@rougier
rougier commented Sep 13, 2011

Ok, I've pushed all suggested changes.

On Sep 13, 2011, at 2:21 , Fernando Perez wrote:

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:

  • go ahead and incorporate the suggestion above into the example
  • add support for --gui pyglet at the command line as indicated above.

Let me know if you need any help. It seems we'll be able to merge this one pretty soon then :)

Reply to this email directly or view it on GitHub:
#743 (comment)

@fperez fperez merged commit db9640d into ipython:master Sep 13, 2011
@fperez
Member
fperez commented Sep 13, 2011

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment