It looks like you have to use window.obj() instead of window because window is the private struct and not the GObject.
window.obj()
window