[IPython-user] Re: [Matplotlib-users] Re: ipython + pylab + wx/wxagg on win32/OSX

John Hunter jdhunter at ace.bsd.uchicago.edu
Thu Sep 9 07:42:15 CDT 2004


>>>>> "Fernando" == Fernando Perez <Fernando.Perez at colorado.edu> writes:

    Fernando> Do you think we'll be able to get the GTK/win32 setup
    Fernando> working?  You probably know that platform better than
    Fernando> anybody else here, so I'm pretty useless on this one.
    Fernando> But it would be great to be able to make a final ipython
    Fernando> release before I get into the 'big cleanup', so that
    Fernando> matplotlib users on all platforms/backends can use pylab
    Fernando> happily while I work on the cleanup.

Gee, some people are never satisfied!

I was able to replicate the gtk win32 problem in the matplotlib
interactive.py, which as you know is based on Brian McErlean and John
Finlay's ASPN cookbook recipe.  However, the original recipe does not
have this bug.  By diffing them, I traced the problem to the call to
gtk.threads_init().  This call is required on linux and OSX, but
breaks win32.  Typical.  So it's a hack but at least it works in my
tests thus far.

In IPython/Shell.py on or around line 424, replace the mainloop
function with 

    def mainloop(self):
        
        self.gtk.timeout_add(self.TIMEOUT, self.IP.runcode)
        if sys.platform != 'win32':
            try:
                if self.gtk.gtk_version[0] >= 2:
                    self.gtk.threads_init()
            except AttributeError:
                pass
        self.start()
        self.gtk.mainloop()
        self.join()

Incidentally, this or some other change appears to fix the GTK OSX
confirm on exit bug (the only other change here is that I call 'start'
after the threads_init call).

Thus I can happily report that with this change and the one you
included in CVS yesterday for output redirection in wx, all the
backends seem to be working across all the major platforms in ipython.

And there was much rejoicing.

JDH





More information about the IPython-user mailing list