How can I retrieve from a GTK Builder the name of an object? [duplicate]
Asked Answered
U

1

2

How do I get the name of a Gtk.Widget retrieved from a Builder object?

I specifically mean the name seen in Glade (eg: button1), not the name of the class (GtkWindow).

This question is exactly the same as this one, but for Python with GObject introspection.

Uncaused answered 13/3, 2013 at 18:6 Comment(0)
U
3

You can't use the get_name method inherited from Gtk.Widget. Instead, you have to use the get_name method defined in Gtk.Buildable, like this:

button = builder.get_object("button1")
print(Gtk.Buildable.get_name(button)) # prints "button1"
Uncaused answered 13/3, 2013 at 18:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.