mirror of
https://github.com/1j01/textual-paint.git
synced 2024-12-22 06:11:37 +03:00
Toggle the color palette with Ctrl+W
Doesn't work in VS Code's terminal, but that's OK. It works in Ubuntu's Terminal app.
This commit is contained in:
parent
4d2b667ecb
commit
a66df997bb
@ -6,7 +6,7 @@ Screen {
|
||||
layout: grid;
|
||||
grid-size: 1;
|
||||
grid-columns: 1fr;
|
||||
grid-rows: 1fr 6;
|
||||
grid-rows: 1fr 0;
|
||||
}
|
||||
|
||||
#main-horizontal-split {
|
||||
@ -22,6 +22,10 @@ Screen {
|
||||
grid-columns: 18 1fr;
|
||||
}
|
||||
|
||||
.show_colors_box #paint {
|
||||
grid-rows: 1fr 6;
|
||||
}
|
||||
|
||||
#editing-area {
|
||||
background: $surface-lighten-3;
|
||||
}
|
||||
|
11
paint.py
11
paint.py
@ -261,6 +261,7 @@ class PaintApp(App):
|
||||
CSS_PATH = "paint.css"
|
||||
|
||||
show_tools_box = var(True)
|
||||
show_colors_box = var(True)
|
||||
selected_tool = var(Tool.pencil)
|
||||
selected_color = var(palette[0])
|
||||
selected_char = var(" ")
|
||||
@ -277,6 +278,14 @@ class PaintApp(App):
|
||||
else:
|
||||
self.add_class("show_tools_box")
|
||||
|
||||
def watch_show_colors_box(self, show_colors_box: bool) -> None:
|
||||
"""Called when show_colors_box changes."""
|
||||
self.query_one("#colors_box").display = show_colors_box
|
||||
if self.has_class("show_colors_box"):
|
||||
self.remove_class("show_colors_box")
|
||||
else:
|
||||
self.add_class("show_colors_box")
|
||||
|
||||
def watch_selected_tool(self, old_selected_tool: Tool, selected_tool: Tool) -> None:
|
||||
"""Called when selected_tool changes."""
|
||||
self.query_one("#tool_button_" + old_selected_tool.name).classes = "tool_button"
|
||||
@ -341,6 +350,8 @@ class PaintApp(App):
|
||||
self.exit()
|
||||
elif key == "ctrl+t":
|
||||
self.show_tools_box = not self.show_tools_box
|
||||
elif key == "ctrl+w":
|
||||
self.show_colors_box = not self.show_colors_box
|
||||
|
||||
def on_button_pressed(self, event: Button.Pressed) -> None:
|
||||
"""Called when a button is pressed."""
|
||||
|
Loading…
Reference in New Issue
Block a user