MCPcopy
hub / github.com/Textualize/textual / __init__

Method __init__

src/textual/widgets/_toggle_button.py:136–170  ·  view source on GitHub ↗

Initialise the toggle. Args: label: The label for the toggle. value: The initial value of the toggle. button_first: Should the button come before the label, or after? name: The name of the toggle. id: The ID of the toggle in the DO

(
        self,
        label: ContentText = "",
        value: bool = False,
        button_first: bool = True,
        *,
        name: str | None = None,
        id: str | None = None,
        classes: str | None = None,
        disabled: bool = False,
        tooltip: RenderableType | None = None,
        compact: bool = False,
    )

Source from the content-addressed store, hash-verified

134 """Enable compact display?"""
135
136 def __init__(
137 self,
138 label: ContentText = "",
139 value: bool = False,
140 button_first: bool = True,
141 *,
142 name: str | None = None,
143 id: str | None = None,
144 classes: str | None = None,
145 disabled: bool = False,
146 tooltip: RenderableType | None = None,
147 compact: bool = False,
148 ) -> None:
149 """Initialise the toggle.
150
151 Args:
152 label: The label for the toggle.
153 value: The initial value of the toggle.
154 button_first: Should the button come before the label, or after?
155 name: The name of the toggle.
156 id: The ID of the toggle in the DOM.
157 classes: The CSS classes of the toggle.
158 disabled: Whether the button is disabled or not.
159 tooltip: RenderableType | None = None,
160 compact: Show a compact button.
161 """
162 super().__init__(name=name, id=id, classes=classes, disabled=disabled)
163 self._button_first = button_first
164 # NOTE: Don't send a Changed message in response to the initial set.
165 with self.prevent(self.Changed):
166 self.value = value
167 self._label = self._make_label(label)
168 if tooltip is not None:
169 self.tooltip = tooltip
170 self.compact = compact
171
172 def _make_label(self, label: ContentText) -> Content:
173 """Make label content.

Callers 1

__init__Method · 0.45

Calls 2

_make_labelMethod · 0.95
preventMethod · 0.80

Tested by

no test coverage detected