I started to build a GUI with Glade, python and Gtk3 libraries. I want to try to view an external window linking it inside a container in my 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.
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.
I unsucessfully tried to change a bit these tutorials with 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). Temporarily the map_area container is a 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!
-intooption for this. (If you are willing to add Xlib as a dependency to your script, you can do this for the other application. I'll post an answer with an example.)XReparentWindow, and you also have access to that function from GdkX11 through thereparentfunction of a window, but at least xterm exits if one tries to reparent an already visible window. So there will be no example from me, sorry.)