Can't embed correctly Window in PyGTK with Socket
I'm following the the tutorial on PyGTK socket where you embed a xterm window to another application.
I downloaded the file from here: http://www.pygtk.org/pygtk2tutorial/examples/socket.py
When I run it following this: http://faq.pygtk.org/index.py?req=show&file=faq19.015.htp I get two different results:
- On Ubuntu Karmic Koala (GTK 2.16) t开发者_如何学编程he xterm appears detached from the socket window and it not usable.
- On Lucid Lynx (GTK 2.17) the xterm window disappears, and the socket window seems to get the background from the xterm, but nothing happens and of course, it's not usable.
I've modified the script to look like this:
#!/usr/bin/python
import pygtk
pygtk.require('2.0')
import gtk
from subprocess import Popen
def plugged_event(widget):
print "Inserted a widget"
window = gtk.Window()
window.connect("destroy", gtk.main_quit)
window.show()
socket = gtk.Socket()
window.add(socket)
socket.connect("plug-added", plugged_event)
sock_id = str(socket.get_id())
cmd = ["xterm", "-into", sock_id]
Popen(cmd)
socket.show()
gtk.main()
Everything seems to work fine, the xterm is embedded to the socket window, but I can't use the keyboard on it and the cursor appears empty. This is the same in either versions of GTK. So, does any one know if this can be fixed or if this is a Bug?
On first glance that seems like a bug in the xterm plug/socketing. I can reproduce on Lucid. If you have vim-gtk installed, replace your cmd with:
cmd = ["gvim", "--socketid", sock_id]
And your script runs fine to embed vim.
精彩评论