Let buttons fall back to the original color when deselected

This commit is contained in:
Isaiah Odhner 2023-04-10 20:52:01 -04:00
parent 3f8a652fe2
commit b64869eae4
2 changed files with 6 additions and 3 deletions

View File

@ -26,6 +26,10 @@ Screen {
height: 100%;
}
#tools_box Button.selected {
background: #aaa;
}
Button {
width: 100%;
height: 100%;

View File

@ -115,9 +115,8 @@ class PaintApp(App):
def watch_selected_tool(self, old_selected_tool: Tool, selected_tool: Tool) -> None:
"""Called when selected_tool changes."""
# TODO: revert to default color defined by built-in style
self.query_one("#tool_button_" + old_selected_tool.name).styles.background = "#555"
self.query_one("#tool_button_" + selected_tool.name).styles.background = "#aaa"
self.query_one("#tool_button_" + old_selected_tool.name).classes = "tool_button"
self.query_one("#tool_button_" + selected_tool.name).classes = "tool_button selected"
def compose(self) -> ComposeResult:
"""Add our widgets."""