Gtk.Buildable

g GObject.GInterface GObject.GInterface Gtk.Buildable Gtk.Buildable GObject.GInterface->Gtk.Buildable

Implementations:

Gtk.CellArea, Gtk.ConstraintLayout, Gtk.EntryCompletion, Gtk.FileFilter, Gtk.ListStore, Gtk.MultiFilter, Gtk.MultiSorter, Gtk.ShortcutController, Gtk.SizeGroup, Gtk.StringList, Gtk.TextTagTable, Gtk.TreeStore, Gtk.TreeViewColumn, Gtk.Widget

Methods

get_buildable_id ()

Virtual Methods

do_add_child (builder, child, type)

do_custom_finished (builder, child, tagname, data)

do_custom_tag_end (builder, child, tagname, data)

do_custom_tag_start (builder, child, tagname)

do_get_id ()

do_get_internal_child (builder, childname)

do_parser_finished (builder)

do_set_buildable_property (builder, name, value)

do_set_id (id)

Properties

None

Signals

None

Fields

None

Class Details

class Gtk.Buildable
Bases:

GObject.GInterface

Structure:

Gtk.BuildableIface

GtkBuildable allows objects to extend and customize their deserialization from ui files.

The interface includes methods for setting names and properties of objects, parsing custom tags and constructing child objects.

The GtkBuildable interface is implemented by all widgets and many of the non-widget objects that are provided by GTK. The main user of this interface is [class`Gtk`.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.

get_buildable_id()[source]
Returns:

the ID of the buildable object

Return type:

str or None

Gets the ID of the self object.

GtkBuilder sets the name based on the ID attribute of the <object> tag used to construct the self.

do_add_child(builder, child, type) virtual
Parameters:

Adds a child to buildable. type is an optional string describing how the child should be added.

do_custom_finished(builder, child, tagname, data) virtual
Parameters:

Similar to gtk_buildable_parser_finished() but is called once for each custom tag handled by the buildable.

do_custom_tag_end(builder, child, tagname, data) virtual
Parameters:
  • builder (Gtk.Builder) – GtkBuilder used to construct this object

  • child (GObject.Object or None) – child object or None for non-child tags

  • tagname (str) – name of tag

  • data (object or None) – user data that will be passed in to parser functions

Called at the end of each custom element handled by the buildable.

do_custom_tag_start(builder, child, tagname) virtual
Parameters:
Returns:

True if an object has a custom implementation, False if it doesn’t.

parser:

a GtkBuildableParser to fill in

data:

return location for user data that will be passed in to parser functions

Return type:

(bool, parser: Gtk.BuildableParser, data: object)

Called for each unknown element under <child>.

do_get_id() virtual
Return type:

str

The getter corresponding to set_id. Implement this if you implement set_id.

do_get_internal_child(builder, childname) virtual
Parameters:
  • builder (Gtk.Builder) – a GtkBuilder

  • childname (str) – name of child

Returns:

the internal child of the buildable object

Return type:

GObject.Object

Retrieves the internal child called childname of the buildable object.

do_parser_finished(builder) virtual
Parameters:

builder (Gtk.Builder) –

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(builder, name, value) virtual
Parameters:

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 [property`Gtk`.Widget:visible] property) until the whole interface is created.

do_set_id(id) virtual
Parameters:

id (str) –

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.