Gtk.Buildable¶
interface
Allows objects to extend and customize deserialization from ui files.
The GtkBuildable interface includes methods for setting names and
properties of objects, parsing custom tags and constructing child objects.
It is implemented by all widgets and many of the non-widget objects that are
provided by GTK. The main user of this interface is Builder.
There should be very little need for applications to call any of these
functions directly.
An object only needs to implement this interface if it needs to extend the
GtkBuilder XML format or run any extra routines at deserialization time.
Methods¶
get_buildable_id¶
Gets the ID of the buildable object.
GtkBuilder sets the name based on the ID attribute
of the <object> tag used to construct the buildable.
Virtual methods¶
do_add_child¶
Adds a child to buildable. type is an optional string
describing how the child should be added.
Parameters:
builder— aGtkBuilderchild— child to addtype— kind of child orNone
do_custom_finished¶
def do_custom_finished(self, builder: Builder, child: GObject.Object | None, tagname: str, data: int | None = ...) -> None
Similar to gtk_buildable_parser_finished() but is
called once for each custom tag handled by the buildable.
Parameters:
builder— aGtkBuilderchild— child object orNonefor non-child tagstagname— the name of the tagdata— user data created in custom_tag_start
do_custom_tag_end¶
def do_custom_tag_end(self, builder: Builder, child: GObject.Object | None, tagname: str, data: int | None = ...) -> None
Called at the end of each custom element handled by the buildable.
Parameters:
builder—GtkBuilderused to construct this objectchild— child object orNonefor non-child tagstagname— name of tagdata— user data that will be passed in to parser functions
do_custom_tag_start¶
def do_custom_tag_start(self, builder: Builder, child: GObject.Object | None, tagname: str) -> tuple[bool, BuildableParser, int]
Called for each unknown element under <child>.
Parameters:
builder— aGtkBuilderused to construct this objectchild— child object orNonefor non-child tagstagname— name of tag
do_get_id¶
The getter corresponding to set_id. Implement this
if you implement set_id.
do_get_internal_child¶
Retrieves the internal child called childname of the buildable object.
Parameters:
builder— aGtkBuilderchildname— name of child
do_parser_finished¶
Called when a builder finishes the parsing
of a UI definition. It is normally not necessary to implement this,
unless you need to perform special cleanup actions. GtkWindow sets
the GtkWidget:visible property here.
do_set_buildable_property¶
Sets a property of a buildable object.
It is normally not necessary to implement this, GObject.Object.set_property
is used by default. GtkWindow implements this to delay showing itself
(i.e. setting the Widget.visible property) until the whole
interface is created.
do_set_id¶
Stores the id attribute given in the GtkBuilder UI definition.
GtkWidget stores the name as object data. Implement this method if your
object has some notion of “ID” and it makes sense to map the XML id
attribute to it.