def runemacs(btn):
    x.set_sensitive(False)
e.set_sensitive(False)
os.spawnlp(os.P_NOWAIT, 'emacs', 'emacs', '--parent-id', str(s.get_id()))

def runxterm(btn):
    x.set_sensitive(False)
e.set_sensitive(False)
os.spawnlp(os.P_NOWAIT, 'xterm', 'xterm', '-into', str(s.get_id()))
e.connect('clicked', runemacs)
x.connect('clicked', runxterm)
w.show_all()
gtk.main()
How to embed some application window in my application using any Python GUI framework