From da3d3b0f0659fb3adba8526552997d39080e24d5 Mon Sep 17 00:00:00 2001 From: Isaiah Odhner Date: Sat, 15 Apr 2023 22:34:24 -0400 Subject: [PATCH] Rename Save As dialog IDs to match Open dialog IDs It's a bit verbose, but for Open, I wanted the _dialog part since "open" can be both a verb and an adjective, and I didn't like it reading as an adjective. It doesn't technically disambiguate it, but it reads better. Verb "[to] open", noun "[dialog to] open", adjective "[part of the dialog to] open" Adjective "[is] open", noun "[dialog that is] open", adjective "[part of the dialog that is] open" Anyways this commit just makes it consistent. Perhaps I could use classes more in place of IDs. --- paint.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/paint.py b/paint.py index 50ab139..bafde45 100644 --- a/paint.py +++ b/paint.py @@ -712,13 +712,13 @@ class PaintApp(App): title="Save As", ) window.content.mount( - DirectoryTree(id="save_as_directory_tree", path="/"), - Input(id="save_as_filename_input", placeholder="Filename"), - Button("Save", id="save_as_save_button", variant="primary"), - Button("Cancel", id="save_as_cancel_button"), + DirectoryTree(id="save_as_dialog_directory_tree", path="/"), + Input(id="save_as_dialog_filename_input", placeholder="Filename"), + Button("Save", id="save_as_dialog_save_button", variant="primary"), + Button("Cancel", id="save_as_dialog_cancel_button"), ) self.mount(window) - self.expand_directory_tree(window.content.query_one("#save_as_directory_tree")) + self.expand_directory_tree(window.content.query_one("#save_as_dialog_directory_tree")) def expand_directory_tree(self, tree: DirectoryTree) -> None: """Expand the directory tree to the target directory, either the folder of the open file or the current working directory.""" @@ -1088,8 +1088,8 @@ class PaintApp(App): self.selected_tool = Tool[button_id[len("tool_button_") :]] elif button_id.startswith("color_button_"): self.selected_color = button_id[len("color_button_") :] - elif button_id == "save_as_save_button": - name = self.query_one("#save_as_filename_input", Input).value + elif button_id == "save_as_dialog_save_button": + name = self.query_one("#save_as_dialog_filename_input", Input).value if name: if self.directory_tree_selected_path: name = os.path.join(self.directory_tree_selected_path, name) @@ -1102,7 +1102,7 @@ class PaintApp(App): else: on_save_confirmed() - elif button_id == "save_as_cancel_button": + elif button_id == "save_as_dialog_cancel_button": self.query_one("#save_as_dialog", Window).close() def on_tree_node_highlighted(self, event: DirectoryTree.FileSelected) -> None: @@ -1117,7 +1117,7 @@ class PaintApp(App): elif event.node.parent: self.directory_tree_selected_path = event.node.parent.data.path name = os.path.basename(event.node.data.path) - self.query_one("#save_as_filename_input, #open_dialog_filename_input", Input).value = name + self.query_one("#save_as_dialog_filename_input, #open_dialog_filename_input", Input).value = name else: self.directory_tree_selected_path = None