.. default-domain:: py .. highlight:: py .. currentmodule:: UI Toggle ====== .. class:: Toggle A control that is either checked or not. Added to a :class:`Canvas` or a :class:`Panel`. .. note:: On its own a toggle is a check box. Put several of them in the same :class:`ToggleGroup` and they become radio buttons, as only one toggle in a group can be checked at a time. | Base class: :class:`InputControl` .. container:: inherited-members .. rubric:: Inherited Members * From :class:`InputControl`: :attr:`~InputControl.changed` * From :class:`Control`: :attr:`~Control.interactable`, :attr:`~Control.color`, :attr:`~Control.tooltip` * From :class:`Object`: :attr:`~Object.rect_transform`, :attr:`~Object.layout_element`, :attr:`~Object.visible`, :meth:`~Object.remove` .. attribute:: text The text for the toggle. :Attribute: Read-only, cannot be set :rtype: :class:`Text` .. attribute:: checked Whether the toggle is checked. :Attribute: Can be read or written :rtype: bool .. note:: Checking a toggle that belongs to a :class:`ToggleGroup` unchecks the rest of that group, whether or not it is on the screen. .. attribute:: group The group that the toggle belongs to, or ``None`` if it does not belong to one. :Attribute: Can be read or written :rtype: :class:`ToggleGroup` or None .. note:: Only one toggle in a group can be checked at a time, so a group turns a set of toggles into radio buttons. A group does not have to contain the toggles, so they can be grouped independently of how they are laid out.