简体   繁体   English

如何在GUI中嵌入外部窗口(Python + Glade + Gtk3)

[英]How to embed external window in GUI (Python + Glade + Gtk3)

I started to build a GUI with Glade, python and Gtk3 libraries. 我开始使用Glade,python和Gtk3库构建GUI。 I want to try to view an external window linking it inside a container in my GUI. 我想尝试查看在GUI中的容器内链接它的外部窗口。 Is it possible? 可能吗? Which is the best container object to do this? 哪个是最好的容器对象呢?

I started to search but easy methods in Gtk2 (like here ) can't be used any more in Gtk3. 我开始搜索,但Gtk2中的简单方法(就像这里 )在Gtk3中不能再使用了。

I found a very interesting post here which allow me to set the right ID of the target window but I'm still confused on how to show it inside my GUI. 我在这里发现了一个非常有趣的帖子它允许我设置目标窗口的正确ID,但我仍然对如何在GUI中显示它感到困惑。

I unsucessfully tried to change a bit these tutorials with cairo. 我没有试图用cairo改变这些教程

My piece of code so far ( I want to display the window with ID = 0x360000b in the map_area container and I have to use the "self." handles structure). 到目前为止我的代码片段(我想在map_area容器中显示ID = 0x360000b的窗口,我必须使用“self。”处理结构)。 Temporarily the map_area container is a Drawingarea. 暂时map_area容器是Drawingarea。

# if condition occurs    
    Gdk.Window.process_all_updates()
    win_id = 0x360000b # from xwininfo command
    root_win = GdkX11.X11Display.get_default()
    win = GdkX11.X11Window.foreign_new_for_display(root_win, win_id)
    width = win.get_width()
    height = win.get_height()   
    self.map_area = cairo.ImageSurface(cairo.FORMAT_ARGB32, width, height)               
    pixbuf = Gdk.pixbuf_get_from_window(win, 0, 0, width, height)
    cr = cairo.Context(self.map_area)   
    Gdk.cairo_set_source_pixbuf(cr, pixbuf, 0, 0)
    cr.paint()

Can anyone help me? 谁能帮我? Thank you in advance! 先感谢您!

It sounds like you want to be a window manager. 听起来你想成为一名窗口管理员。 Have a look at the answers to questions about how to write a window manager, such as this one: 看看有关如何编写窗口管理器的问题的答案,例如:

Creating a window manager for Linux 为Linux创建窗口管理器

or this one: 或者这个:

Building a Window Manager 构建一个窗口管理器

Good luck! 祝好运!

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

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