#!/usr/bin/python3

from gi.repository import Gtk

Gtk.init()


box = Gtk.Box()

def focus_in(widget, event):
    print ("in")
def focus_out(widget, event):
    print ("out", event.window, widget.get_parent())
    box.remove(widget)
entry = Gtk.Entry()
entry.connect("focus-in-event", focus_in)
entry.connect("focus-out-event", focus_out)
entry.show()
box.add(entry)


win = Gtk.Window()

win.add(box)
win.show_all()

win.connect("delete-event", Gtk.main_quit)
Gtk.main()
