简体   繁体   English

pygtk如何在我的pygtk GUI中嵌入外部应用程序

[英]pygtk how to embed external application within my pygtk GUI

I'm desiging a pygtk GUI and want to embed an external application into it. 我正在设计一个pygtk GUI,并希望将一个外部应用程序嵌入其中。

Does anyone have any idea how this can be done? 有谁知道如何做到这一点?

It depends on what application you are trying to embed into yours, but if the other app is a GTK app (or one that supports the XEMBED protocol), you should be able to do this with gtk.Plug and gtk.Socket . 这取决于您尝试嵌入到您的应用程序中,但如果其他应用程序是GTK应用程序(或支持XEMBED协议的应用程序),您应该可以使用gtk.Pluggtk.Socket执行此操作 The PyGTK tutorial has a section explaining how to do this: PyGTK教程有一节解释如何执行此操作:

http://www.pygtk.org/pygtk2tutorial/sec-PlugsAndSockets.html http://www.pygtk.org/pygtk2tutorial/sec-PlugsAndSockets.html

This one might help. 这可能会有所帮助。 Read the article 19.15. 阅读文章19.15。 How do I embed something using Plugs and Sockets? 如何使用插头和插座嵌入东西? ( http://faq.pygtk.org/index.py?req=all#19.15 ) and find out how to embed arbitrary X Window application into (Py)GTK Socket. http://faq.pygtk.org/index.py?req=all#19.15 )并了解如何将任意X Window应用程序嵌入(Py)GTK Socket。

You don't use an external program to get the gtk.Plug / gtk.Socket ID, they have their respective functions for that. 您不使用外部程序来获取gtk.Plug / gtk.Socket ID,它们各自具有相应的功能。 See this tutorial for examples: link . 有关示例,请参阅本教程: 链接

If you're trying to reparent an external window (that may not be a gtk window), you can use 如果您尝试重新显示外部窗口(可能不是gtk窗口),则可以使用

w = gdk.window_foreign_new(window_id)

to get a gdk window object from an operating system window handle, and then use 从操作系统窗口句柄获取gdk窗口对象,然后使用

w.reparent(parent_window, x, y)

to reparent it into an existing gtk container. 将其重新映射到现有的gtk容器中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM