mirror of
https://github.com/1j01/textual-paint.git
synced 2025-01-02 20:04:36 +03:00
Toggle the tools box with Ctrl+T
This commit is contained in:
parent
ae73fab2f4
commit
4d2b667ecb
@ -13,11 +13,15 @@ Screen {
|
|||||||
layout: grid;
|
layout: grid;
|
||||||
grid-size: 2;
|
grid-size: 2;
|
||||||
grid-gutter: 1 2;
|
grid-gutter: 1 2;
|
||||||
grid-columns: 18 1fr;
|
grid-columns: 0 1fr;
|
||||||
grid-rows: 1fr;
|
grid-rows: 1fr;
|
||||||
margin: 0 0;
|
margin: 0 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.show_tools_box #main-horizontal-split {
|
||||||
|
grid-columns: 18 1fr;
|
||||||
|
}
|
||||||
|
|
||||||
#editing-area {
|
#editing-area {
|
||||||
background: $surface-lighten-3;
|
background: $surface-lighten-3;
|
||||||
}
|
}
|
||||||
|
14
paint.py
14
paint.py
@ -260,7 +260,7 @@ class PaintApp(App):
|
|||||||
|
|
||||||
CSS_PATH = "paint.css"
|
CSS_PATH = "paint.css"
|
||||||
|
|
||||||
# show_tools_box = var(True)
|
show_tools_box = var(True)
|
||||||
selected_tool = var(Tool.pencil)
|
selected_tool = var(Tool.pencil)
|
||||||
selected_color = var(palette[0])
|
selected_color = var(palette[0])
|
||||||
selected_char = var(" ")
|
selected_char = var(" ")
|
||||||
@ -269,9 +269,13 @@ class PaintApp(App):
|
|||||||
# key to button id
|
# key to button id
|
||||||
}
|
}
|
||||||
|
|
||||||
# def watch_show_tools_box(self, show_tools_box: bool) -> None:
|
def watch_show_tools_box(self, show_tools_box: bool) -> None:
|
||||||
# """Called when show_tools_box changes."""
|
"""Called when show_tools_box changes."""
|
||||||
# self.query_one("#tools_box").display = not show_tools_box
|
self.query_one("#tools_box").display = show_tools_box
|
||||||
|
if self.has_class("show_tools_box"):
|
||||||
|
self.remove_class("show_tools_box")
|
||||||
|
else:
|
||||||
|
self.add_class("show_tools_box")
|
||||||
|
|
||||||
def watch_selected_tool(self, old_selected_tool: Tool, selected_tool: Tool) -> None:
|
def watch_selected_tool(self, old_selected_tool: Tool, selected_tool: Tool) -> None:
|
||||||
"""Called when selected_tool changes."""
|
"""Called when selected_tool changes."""
|
||||||
@ -335,6 +339,8 @@ class PaintApp(App):
|
|||||||
press(self.NAME_MAP.get(key, key))
|
press(self.NAME_MAP.get(key, key))
|
||||||
elif key == "ctrl+q" or key == "meta+q":
|
elif key == "ctrl+q" or key == "meta+q":
|
||||||
self.exit()
|
self.exit()
|
||||||
|
elif key == "ctrl+t":
|
||||||
|
self.show_tools_box = not self.show_tools_box
|
||||||
|
|
||||||
def on_button_pressed(self, event: Button.Pressed) -> None:
|
def on_button_pressed(self, event: Button.Pressed) -> None:
|
||||||
"""Called when a button is pressed."""
|
"""Called when a button is pressed."""
|
||||||
|
Loading…
Reference in New Issue
Block a user