无法使用 Socket 在 PyGTK 中正确嵌入 Window
我正在关注 PyGTK 套接字的教程,您可以在其中将 xterm 窗口嵌入到另一个应用程序中。
我从这里下载了该文件: http://www.pygtk.org/pygtk2tutorial/examples /socket.py
当我按照以下方式运行它时: http://faq.pygtk.org/index.py?req=show&file=faq19.015.htp 我得到两个不同的结果:
- 在 Ubuntu Karmic Koala (GTK 2.16) 上,xterm 显示为分离的从套接字窗口,它不可用。
- 在 Lucid Lynx (GTK 2.17) 上,xterm 窗口消失,套接字窗口似乎从 xterm 获得背景,但没有任何反应,当然,它不可用。
我已将脚本修改为如下所示:
#!/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()
一切似乎都工作正常,xterm 嵌入到套接字窗口中,但我无法在其上使用键盘,并且光标显示为空。这在 GTK 的两个版本中都是相同的。那么,有谁知道这是否可以修复或者这是否是一个错误?
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) the 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
乍一看,这似乎是 xterm 插头/插座中的一个错误。我可以在 Lucid 上重现。如果您安装了 vim-gtk,请将您的 cmd 替换为:
并且您的脚本可以正常运行以嵌入 vim。
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:
And your script runs fine to embed vim.