I have the following Python 2.7/PyGObject 3.0/PyGST 0.10 module:
from gi.repository import Gtk, Gdk, GdkPixbuf
import pango
import pygst
pygst.require(\'0.10
(Reprinted from GNOME PyGObject 3 Bug Report 663360. Answer credit goes to Timo Vanwynsberghe).
There are a couple of things to note: - the drawingarea has to be realised before you can get its GdkWindow - apparently, you can't get the window property directly - you need to import GdkX11 for the xid method
With this in mind, here is a minimal working example:
from gi.repository import GdkX11, Gtk
class App:
def __init__(self):
win = Gtk.Window()
win.resize(400, 400)
win.connect('delete-event', Gtk.main_quit)
da = Gtk.DrawingArea()
win.add(da)
win.show_all()
print da.get_property('window').get_xid()
if __name__ == "__main__":
App()
Gtk.main()