:right-sidebar: True Expander =================================================================== .. currentmodule:: gi.repository.Gtk .. class:: Expander(**properties: ~typing.Any) :no-contents-entry: Superclasses: :class:`~gi.repository.Gtk.Widget`, :class:`~gi.repository.GObject.InitiallyUnowned`, :class:`~gi.repository.GObject.Object` Implemented Interfaces: :class:`~gi.repository.Gtk.Accessible`, :class:`~gi.repository.Gtk.Buildable`, :class:`~gi.repository.Gtk.ConstraintTarget` :Constructors: :: Expander(**properties) new(label:str=None) -> Gtk.Widget new_with_mnemonic(label:str=None) -> Gtk.Widget Constructors ------------ .. rst-class:: interim-class .. class:: Expander :no-index: .. classmethod:: new(label: str | None = None) -> ~gi.repository.Gtk.Widget Creates a new expander using ``label`` as the text of the label. :param label: the text of the label .. classmethod:: new_with_mnemonic(label: str | None = None) -> ~gi.repository.Gtk.Widget Creates a new expander using ``label`` as the text of the label. If characters in ``label`` are preceded by an underscore, they are underlined. If you need a literal underscore character in a label, use “``__``” (two underscores). The first underlined character represents a keyboard accelerator called a mnemonic. Pressing Alt and that key activates the button. :param label: the text of the label with an underscore in front of the mnemonic character Methods ------- .. rst-class:: interim-class .. class:: Expander :no-index: .. method:: get_child() -> ~gi.repository.Gtk.Widget | None Gets the child widget of ``expander``. .. method:: get_expanded() -> bool Queries a ``GtkExpander`` and returns its current state. Returns :const:`True` if the child widget is revealed. .. method:: get_label() -> str | None Fetches the text from a label widget. This is including any embedded underlines indicating mnemonics and Pango markup, as set by :obj:`~gi.repository.Gtk.Expander.set_label`. If the label text has not been set the return value will be :const:`None`. This will be the case if you create an empty button with :func:`~gi.repository.Gtk.Button.new` to use as a container. .. method:: get_label_widget() -> ~gi.repository.Gtk.Widget | None Retrieves the label widget for the frame. .. method:: get_resize_toplevel() -> bool Returns whether the expander will resize the toplevel widget containing the expander upon resizing and collapsing. .. method:: get_use_markup() -> bool Returns whether the label’s text is interpreted as Pango markup. .. method:: get_use_underline() -> bool Returns whether an underline in the text indicates a mnemonic. .. method:: set_child(child: ~gi.repository.Gtk.Widget | None = None) -> None Sets the child widget of ``expander``. :param child: the child widget .. method:: set_expanded(expanded: bool) -> None Sets the state of the expander. Set to :const:`True`, if you want the child widget to be revealed, and :const:`False` if you want the child widget to be hidden. :param expanded: whether the child widget is revealed .. method:: set_label(label: str | None = None) -> None Sets the text of the label of the expander to ``label``. This will also clear any previously set labels. :param label: a string .. method:: set_label_widget(label_widget: ~gi.repository.Gtk.Widget | None = None) -> None Set the label widget for the expander. This is the widget that will appear embedded alongside the expander arrow. :param label_widget: the new label widget .. method:: set_resize_toplevel(resize_toplevel: bool) -> None Sets whether the expander will resize the toplevel widget containing the expander upon resizing and collapsing. :param resize_toplevel: whether to resize the toplevel .. method:: set_use_markup(use_markup: bool) -> None Sets whether the text of the label contains Pango markup. :param use_markup: :const:`True` if the label’s text should be parsed for markup .. method:: set_use_underline(use_underline: bool) -> None If true, an underline in the text indicates a mnemonic. :param use_underline: :const:`True` if underlines in the text indicate mnemonics Properties ---------- .. rst-class:: interim-class .. class:: Expander :no-index: .. attribute:: props.child :type: ~gi.repository.Gtk.Widget The child widget. .. attribute:: props.expanded :type: bool Whether the expander has been opened to reveal the child. .. attribute:: props.label :type: str The text of the expanders label. .. attribute:: props.label_widget :type: ~gi.repository.Gtk.Widget A widget to display instead of the usual expander label. .. attribute:: props.resize_toplevel :type: bool When this property is :const:`True`, the expander will resize the toplevel widget containing the expander upon expanding and collapsing. .. attribute:: props.use_markup :type: bool Whether the text in the label is Pango markup. .. attribute:: props.use_underline :type: bool Whether an underline in the text indicates a mnemonic. Signals ------- .. rst-class:: interim-class .. class:: Expander.signals :no-index: .. method:: activate() -> None Activates the ``GtkExpander``.