Refactor: use set_class instead of add_class/remove_class

This commit is contained in:
Isaiah Odhner 2023-05-04 23:30:28 -04:00
parent f701d04b9d
commit 4f08072a75

View File

@ -1564,10 +1564,8 @@ class PaintApp(App[None]):
"""Called when selected_tool changes."""
for button in self.query(".tool_button"):
assert isinstance(button, Button)
if selected_tool == self.query_one("ToolsBox", ToolsBox).tool_by_button[button]:
button.add_class("selected")
else:
button.remove_class("selected")
button_tool = self.query_one("ToolsBox", ToolsBox).tool_by_button[button]
button.set_class(selected_tool == button_tool, "selected")
def watch_selected_bg_color(self, selected_bg_color: str) -> None:
"""Called when selected_bg_color changes."""