[IPython-user] embedding a shell in gtk app

Fernando Perez Fernando.Perez at colorado.edu
Wed Feb 2 12:55:54 CST 2005


John Hunter wrote:
> I have a gtk app that I would like to interact with from the shell.  I
> am wondering if this is possible with the new changes to support gtk
> threading.  The naive thing, just using IPShellEmbed, freezes the
> app.  Here is the play gtk app I am testing with
> 
> Basically, I want to be able to access interactively some vtk objects
> my app creates, to call methods on them, etc.  I am not interested in
> scripting the GTK specific stuff at this time....

OK, I hate to say this, but with all the matshow() work, I'm badly behind on 
other things and I won't be able to dive into this til later.  Esp. because 
this may take some careful work for a permanent solution.  But in the 
meantime, I can offer some pointers to get you started.

1. The best solution would be to work with IPython/Shell.py.  I think what we 
need to do is make an embeeded version of IPShellGTK, which already has all 
the GTK threading machinery.  You did much of this already (you wrote a good 
chunk of that code), so it shouldn't be too bad.  The question is what the 
cleanest class hierarchy would be in that file, to avoid much duplication.  I 
think with the matplotlib shell classes we got a decent organization, but I 
never included the Embed class in all of that design.  So a bit of shuffling 
around of code might be needed.

2. If you want to play with a much simpler design, use the pyint-gtk stuff I 
sent you recently to replace interactive.py.  I just had a look at the mpl CVS 
tree, and it's already in there (I think Steve committed it).  That code 
addresses fundamentally the same problem, and it is based on the same console 
class as ipython, while being far smaller and easier to deal with.  If 
Shell.py feels too daunting, you might get something working with this guy.  I 
should be able to fold any such work into ipython proper later on.


Note that #1 might really be the way to go in the long run, even if the code 
is a bit more complex.  It's the right long-term solution, and the *Embed 
class already has the namespace handling machinery necessary for embedded 
applications.

I promise I'll work with your code as soon as I can, but I _really_ need to 
continue writing the stuff which led me to the matshow() effort.

Cheers,

f




More information about the IPython-user mailing list