:right-sidebar: True Box =================================================================== .. currentmodule:: gi.repository.Gtk .. class:: Box(**properties: ~typing.Any) :no-contents-entry: Superclasses: :class:`~gi.repository.Gtk.Widget`, :class:`~gi.repository.GObject.InitiallyUnowned`, :class:`~gi.repository.GObject.Object` Subclasses: :class:`~gi.repository.Gtk.ShortcutsGroup`, :class:`~gi.repository.Gtk.ShortcutsSection` Implemented Interfaces: :class:`~gi.repository.Gtk.Accessible`, :class:`~gi.repository.Gtk.Buildable`, :class:`~gi.repository.Gtk.ConstraintTarget`, :class:`~gi.repository.Gtk.Orientable` :Constructors: :: Box(**properties) new(orientation:Gtk.Orientation, spacing:int) -> Gtk.Widget Constructors ------------ .. rst-class:: interim-class .. class:: Box :no-index: .. classmethod:: new(orientation: ~gi.repository.Gtk.Orientation, spacing: int) -> ~gi.repository.Gtk.Widget Creates a new ``GtkBox``. :param orientation: the box’s orientation :param spacing: the number of pixels to place by default between children Methods ------- .. rst-class:: interim-class .. class:: Box :no-index: .. method:: append(child: ~gi.repository.Gtk.Widget) -> None Adds ``child`` as the last child to ``box``. :param child: the ``GtkWidget`` to append .. method:: get_baseline_child() -> int Gets the value set by :func:`~gi.repository.Gtk.Box.set_baseline_child`. .. versionadded:: 4.12 .. method:: get_baseline_position() -> ~gi.repository.Gtk.BaselinePosition Gets the value set by :func:`~gi.repository.Gtk.Box.set_baseline_position`. .. method:: get_homogeneous() -> bool Returns whether the box is homogeneous (all children are the same size). .. method:: get_spacing() -> int Gets the value set by :func:`~gi.repository.Gtk.Box.set_spacing`. .. method:: insert_child_after(child: ~gi.repository.Gtk.Widget, sibling: ~gi.repository.Gtk.Widget | None = None) -> None Inserts ``child`` in the position after ``sibling`` in the list of ``box`` children. If ``sibling`` is :const:`None`, insert ``child`` at the first position. :param child: the ``GtkWidget`` to insert :param sibling: the sibling after which to insert ``child`` .. method:: prepend(child: ~gi.repository.Gtk.Widget) -> None Adds ``child`` as the first child to ``box``. :param child: the ``GtkWidget`` to prepend .. method:: remove(child: ~gi.repository.Gtk.Widget) -> None Removes a child widget from ``box``. The child must have been added before with :obj:`~gi.repository.Gtk.Box.append`, :obj:`~gi.repository.Gtk.Box.prepend`, or :obj:`~gi.repository.Gtk.Box.insert_child_after`. :param child: the child to remove .. method:: reorder_child_after(child: ~gi.repository.Gtk.Widget, sibling: ~gi.repository.Gtk.Widget | None = None) -> None Moves ``child`` to the position after ``sibling`` in the list of ``box`` children. If ``sibling`` is :const:`None`, move ``child`` to the first position. :param child: the ``GtkWidget`` to move, must be a child of ``box`` :param sibling: the sibling to move ``child`` after .. method:: set_baseline_child(child: int) -> None Sets the baseline child of a box. This affects only vertical boxes. .. versionadded:: 4.12 :param child: a child, or -1 .. method:: set_baseline_position(position: ~gi.repository.Gtk.BaselinePosition) -> None Sets the baseline position of a box. This affects only horizontal boxes with at least one baseline aligned child. If there is more vertical space available than requested, and the baseline is not allocated by the parent then ``position`` is used to allocate the baseline with respect to the extra space available. :param position: a ``GtkBaselinePosition`` .. method:: set_homogeneous(homogeneous: bool) -> None Sets whether or not all children of ``box`` are given equal space in the box. :param homogeneous: a boolean value, :const:`True` to create equal allotments, :const:`False` for variable allotments .. method:: set_spacing(spacing: int) -> None Sets the number of pixels to place between children of ``box``. :param spacing: the number of pixels to put between children Properties ---------- .. rst-class:: interim-class .. class:: Box :no-index: .. attribute:: props.baseline_child :type: int The child that determines the baseline, in vertical orientation. .. versionadded:: 4.12 .. attribute:: props.baseline_position :type: ~gi.repository.Gtk.BaselinePosition The position of the baseline aligned widgets if extra space is available. .. attribute:: props.homogeneous :type: bool Whether the children should all be the same size. .. attribute:: props.spacing :type: int The amount of space between children. Fields ------ .. rst-class:: interim-class .. class:: Box :no-index: .. attribute:: parent_instance