Gtk3 integration with ipython works. #1588

Merged
merged 7 commits into from Apr 14, 2012

3 participants

@thomir

This branch adds support for interactive Gtk3 UI support.

The older Gtk2 bindings (pygtk) are being deprecated in the wild, in favor of the newer gi bindings. This allows users to use new features in Gtk3. This is a very simple branch, that follows the same pattern as the 'gtk' UI support feature, but for Gtk3.

@fperez
IPython member

Do you have any tests we can use to see this functionality at work? It could be an interactive example that goes into docs/examples/lib if it's hard to unittest this...

Also, since this adds a 'gtk3' target for the %gui magic, the docstring for magic_gui needs to be updated to show that gtk3 is also a valid value.

@thomir

Hi,

Thanks for looking at this. Both changes have been made now. I added a docstring to the %gui magic function. I notice that the UI types weren't listed alphabetically, so I put the docstring for 'gtk3' right below the docstring or 'gtk'. As far as testing is concerned, I've followed the pattern for the 'gtk' Gui integration.

@takluyver takluyver commented on an outdated diff Apr 14, 2012
IPython/core/magic.py
@@ -94,7 +94,7 @@ def needs_local_scope(func):
func.needs_local_scope = True
return func
-
+
@takluyver
IPython member
takluyver added a line comment Apr 14, 2012

For future reference: please try to avoid whitespace changes in functional pull requests, because it makes it hard to see what's really changed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@takluyver takluyver commented on an outdated diff Apr 14, 2012
docs/examples/lib/gui-gtk3.py
@@ -0,0 +1,37 @@
+#!/usr/bin/env python
+"""Simple Gtk example to manually test event loop integration.
+
+This is meant to run tests manually in ipython as:
+
+In [1]: %gui gtk3
+
+In [2]: %run gui-gtk3.py
+"""
+
+from gi.repository import Gtk
+
+
+def hello_world(wigdet, data=None):
+ print "Hello World"
@takluyver
IPython member
takluyver added a line comment Apr 14, 2012

Can you change this to print("Hello World") so it's easy to test from Python 3 (I've just done it locally, and it does work). The brackets are valid in Python 2 for a single argument.

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

@thomir, it seems that (in addition to the small fix suggested by @takluyver), this PR now has a conflict with master, likelye something small that's colliding with other recently merged code. We'll have to ask you to rebase it before we can merge it, unfortunately.

Let us know if you need help with that and we'll give you a hand. Once you rebase and make that small fix I'll take care of merging it quickly so this doesn't happen again.

@takluyver
IPython member

It may well be the whitespace changes conflicting with a change in nearby lines.

@fperez
IPython member

Yes, very likely, though I haven't confirmed yet by looking at the conflicts.

@thomir

Hi,

Sorry about the whitespace changes - my editor automatically strips trailing whitespace, so I didn't even notice I had done this.

I've merged trunk, and fixed the conflicts. I think I've done this correctly, although I'm using the git backend to bzr, so there's a chance it's not correct.

Thanks again for looking at this.

@takluyver takluyver commented on an outdated diff Apr 14, 2012
IPython/core/magic.py
contents = openpy.read_py_file(arg_s, skip_encoding_cookie=True)
self.set_next_input(contents)
+>>>>>>> MERGE-SOURCE
@takluyver
IPython member
takluyver added a line comment Apr 14, 2012

Nope, this merge didn't quite go right.

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

The docstring change for the %gui magic seems to have gone missing after the latest merge.

@thomir

OK, I figured out how to use rebase properly :)

@thomir

whitespace-only changes reverted.

@takluyver takluyver merged commit 9096723 into ipython:master Apr 14, 2012
@takluyver
IPython member

@fperez already OKed the changes, so I've merged this.

@fperez
IPython member

Many thanks to all!

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