Bring the button_first setting internal

This was a reactive, the idea being that folk could swap the layout of a
button the fly, but the request has been made that we don't go quite so OTT
with the ability to configure.
This commit is contained in:
Dave Pearson
2023-02-22 13:30:44 +00:00
parent 5743148ce8
commit 23cc1daca1

View File

@@ -82,9 +82,6 @@ class ToggleButton(Static, can_focus=True):
value: reactive[bool] = reactive(False)
"""The value of the button. `True` for on, `False` for off."""
button_first: reactive[bool] = reactive(True)
"""Should the button come before the label?"""
def __init__(
self,
label: TextType,
@@ -108,7 +105,7 @@ class ToggleButton(Static, can_focus=True):
disabled: Whether the button is disabled or not.
"""
super().__init__(name=name, id=id, classes=classes, disabled=disabled)
self.button_first = button_first
self._button_first = button_first
self.value = value
self.label: Text = Text.from_markup(label) if isinstance(label, str) else label
"""The label for the button."""
@@ -138,7 +135,7 @@ class ToggleButton(Static, can_focus=True):
spacer = Text(" " if self.label else "")
return (
Text.assemble(button, spacer, label)
if self.button_first
if self._button_first
else Text.assemble(label, spacer, button)
)