From 7fb20baae1413fd1ead99f700fc891d6ee7807dd 2010-12-29 02:18:14
From: Paul Ivanov <pivanov314@gmail.com>
Date: 2010-12-29 02:18:14
Subject: [PATCH] remove set_interactive gtk check (fix #185)

It was unclear why the function check_gtk() was added in the first
place, but plt.show() blocked when using "ipython -gthread" without
the "-pylab"

also, I just want to note here that users will still experience blocking
behaviour if they use e.g "ipython -gthread" but their matplotlib is set
to some other backend by default (say "WX").

---

diff --git a/IPython/Shell.py b/IPython/Shell.py
index 38006d7..f07337d 100644
--- a/IPython/Shell.py
+++ b/IPython/Shell.py
@@ -1149,19 +1149,6 @@ class IPShellMatplotlibQt4(IPShellQt4):
 #-----------------------------------------------------------------------------
 # Factory functions to actually start the proper thread-aware shell
 
-def check_gtk(mode):
-    try:
-        import gtk
-    except (ImportError, RuntimeError):
-        # GTK not present, or can't be started (no X11, happens in console)
-        return mode
-    if hasattr(gtk,'set_interactive'):
-        gtk.set_interactive(False)
-        return 'tkthread'
-    else:
-        return mode
-
-
 def _select_shell(argv):
     """Select a shell from the given argv vector.
 
@@ -1231,10 +1218,6 @@ def _select_shell(argv):
             else:
                 # Any other backend, use plain Tk
                 th_mode = 'tkthread'
-
-            # New versions of pygtk don't need the brittle threaded support.
-            th_mode = check_gtk(th_mode)
-                
         return mpl_shell[th_mode]
     else:
         # No pylab requested, just plain threads
@@ -1242,10 +1225,6 @@ def _select_shell(argv):
             th_mode = special_opts.pop()
         except KeyError:
             th_mode = 'tkthread'
-
-        # New versions of pygtk don't need the brittle threaded support.
-        if th_mode == 'gthread':
-            th_mode = check_gtk(th_mode)
         return th_shell[th_mode]