From 7e6911bf9bf061a11e87f74db0033a41cd530f19 Mon Sep 17 00:00:00 2001 From: Darren Burns Date: Mon, 14 Oct 2024 10:13:35 +0100 Subject: [PATCH] Remove ToggleButton styling switcheroo --- src/textual/widgets/_radio_set.py | 23 +++++++++-------------- src/textual/widgets/_toggle_button.py | 7 ------- 2 files changed, 9 insertions(+), 21 deletions(-) diff --git a/src/textual/widgets/_radio_set.py b/src/textual/widgets/_radio_set.py index 83eda636ce..d3b8a77841 100644 --- a/src/textual/widgets/_radio_set.py +++ b/src/textual/widgets/_radio_set.py @@ -36,12 +36,17 @@ class RadioSet(VerticalScroll, can_focus=True, can_focus_children=False): & > RadioButton { background: transparent; border: none; - padding: 0 1; + padding: 0; } & > RadioButton.-selected { color: $text; background: $highlight-cursor-blurred; + + & > .toggle--button { + color: $surface; + background: $foreground 15%; + } } & .toggle--button { @@ -59,29 +64,19 @@ class RadioSet(VerticalScroll, can_focus=True, can_focus_children=False): */ border: tall $border; - & .toggle--button { - color: $surface; - background: $panel-lighten-1; - } - & > RadioButton.-selected { color: $text; background: $highlight-cursor; - - & > .toggle--label { - background: $highlight-cursor; + & > .toggle--button { + color: $surface; + background: $panel-lighten-1; } - &.-on > .toggle--button { color: $success; background: $panel-lighten-1; } } - & ToggleButton.-selected > .toggle--button { - color: $surface; - background: $panel-lighten-1; - } } } """ diff --git a/src/textual/widgets/_toggle_button.py b/src/textual/widgets/_toggle_button.py index 40f7690e8e..d34a5cfd4e 100644 --- a/src/textual/widgets/_toggle_button.py +++ b/src/textual/widgets/_toggle_button.py @@ -191,13 +191,6 @@ def _button(self) -> Text: # Grab the button style. button_style = self.get_component_rich_style("toggle--button") - # If the button is off, we're going to do a bit of a switcharound to - # make it look like it's a "cutout". - if not self.value: - button_style += Style.from_color( - self.background_colors[1].rich_color, button_style.bgcolor - ) - # Building the style for the side characters. Note that this is # sensitive to the type of character used, so pay attention to # BUTTON_LEFT and BUTTON_RIGHT.