I\'m looking for a way to remove a widget from its parent (whatever that may be - a VBox, a Grid, ...) and add a substitute widget in its place.
I found this answer,
Thanks to the information provided by ptomato's answer, here's the working code:
def replace_widget(old, new):
parent = old.get_parent()
props = {}
for key in Gtk.ContainerClass.list_child_properties(type(parent)):
props[key.name] = parent.child_get_property(old, key.name)
parent.remove(old)
parent.add(new)
for name, value in props.iteritems():
parent.child_set_property(new, name, value)