[IPython-user] embedding a shell in gtk app
John Hunter
jdhunter at ace.bsd.uchicago.edu
Wed Feb 2 10:39:09 CST 2005
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....
JDH
import pygtk
pygtk.require('2.0')
import gtk
def hello(event):
print "Hello World"
return gtk.TRUE
window = gtk.Window()
window.set_name("Test Input")
window.connect("destroy", gtk.mainquit)
vbox = gtk.VBox(spacing=3)
window.add(vbox)
vbox.show()
button = gtk.Button("Hello World")
button.connect("clicked", hello)
button.show()
vbox.pack_start(button, expand=gtk.FALSE, fill=gtk.FALSE)
from IPython.Shell import IPShellEmbed
def ishell(*args):
ipshell = IPShellEmbed([], banner='Pea brains, untie!')
ipshell(header='This is not a header')
button = gtk.Button("Shell")
button.connect("clicked", ishell)
button.show()
vbox.pack_start(button, expand=gtk.FALSE, fill=gtk.FALSE)
button = gtk.Button("Quit")
button.connect("clicked", gtk.mainquit)
button.show()
vbox.pack_start(button, expand=gtk.FALSE, fill=gtk.FALSE)
window.show()
gtk.mainloop()
More information about the IPython-user
mailing list