##// END OF EJS Templates
Added GTK support to ZeroMQ kernel....
Added GTK support to ZeroMQ kernel. We use an approach which is a combination of an gtk timer callback into our execution loop, like we do for Qt and Wx, I've run as tests several GTK examples found on the net, as well as multiple matplotlib scripts, and so far everything works as expected. The only catch is that we silently trap gtk.main_quit(), so examples that call it with a 'close' button or similar seem to not do anything. But their windows close normally and no other problems have been found. This solution uses code taken from an old bug report of ours: https://bugs.launchpad.net/ipython/+bug/270856 specifically the attachment in this comment: https://bugs.launchpad.net/ipython/+bug/270856/comments/6 along with the changes suggested by Michiel de Hoon there. Thanks to Ville and Michiel for that old discussion, which put me on the right track to figure out the details of the logic needed for GTK.

File last commit:

r2267:928c921b
r2949:13751b1c
Show More
ipy_legacy.py
62 lines | 1.9 KiB | text/x-python | PythonLexer
""" Legacy stuff
Various stuff that are there for historical / familiarity reasons.
This is automatically imported by default profile, though not other profiles
(e.g. 'sh' profile).
Stuff that is considered obsolete / redundant is gradually moved here.
"""
from IPython.core import ipapi
ip = ipapi.get()
import os,sys
from IPython.utils.genutils import *
# use rehashx
def magic_rehash(self, parameter_s = ''):
"""Update the alias table with all entries in $PATH.
This version does no checks on execute permissions or whether the
contents of $PATH are truly files (instead of directories or something
else). For such a safer (but slower) version, use %rehashx."""
# This function (and rehashx) manipulate the alias_table directly
# rather than calling magic_alias, for speed reasons. A rehash on a
# typical Linux box involves several thousand entries, so efficiency
# here is a top concern.
path = filter(os.path.isdir,os.environ.get('PATH','').split(os.pathsep))
alias_table = self.shell.alias_table
for pdir in path:
for ff in os.listdir(pdir):
# each entry in the alias table must be (N,name), where
# N is the number of positional arguments of the alias.
alias_table[ff] = (0,ff)
# Make sure the alias table doesn't contain keywords or builtins
self.shell.alias_table_validate()
# Call again init_auto_alias() so we get 'rm -i' and other modified
# aliases since %rehash will probably clobber them
self.shell.init_auto_alias()
ip.define_magic("rehash", magic_rehash)
# Exit
def magic_Quit(self, parameter_s=''):
"""Exit IPython without confirmation (like %Exit)."""
self.shell.ask_exit()
ip.define_magic("Quit", magic_Quit)
# make it autocallable fn if you really need it
def magic_p(self, parameter_s=''):
"""Just a short alias for Python's 'print'."""
exec 'print ' + parameter_s in self.shell.user_ns
ip.define_magic("p", magic_p)