diff --git a/paint.py b/paint.py index 36408bc..03191cb 100644 --- a/paint.py +++ b/paint.py @@ -24,7 +24,7 @@ from textual.widget import Widget from textual.widgets import Button, Static, Input, DirectoryTree, Header from textual.color import Color from menus import MenuBar, Menu, MenuItem, Separator -from windows import Window, DialogWindow, CharacterSelectorDialogWindow, warning_message_box +from windows import Window, DialogWindow, CharacterSelectorDialogWindow, create_warning_message_box from localization.i18n import get as _, load_language @@ -1151,7 +1151,14 @@ class PaintApp(App): restart_program() def warning_message_box(self, title: str, message_widget: Widget, button_types: str = "ok", callback = None) -> None: - warning_message_box(self, title, message_widget, button_types, callback) + + for old_window in self.query("#message_box").nodes: + old_window.close() + + self.bell() + + window = create_warning_message_box(title, message_widget, button_types, callback) + self.mount(window) def action_open(self) -> None: """Show dialog to open an image from a file.""" diff --git a/windows.py b/windows.py index 3f42ef6..ef3c370 100644 --- a/windows.py +++ b/windows.py @@ -227,16 +227,10 @@ class CharacterSelectorDialogWindow(DialogWindow): self.content.mount(Button("Cancel", classes="cancel")) -def warning_message_box(app, title: str, message_widget: Widget, button_types: str = "ok", callback = None) -> None: - +def create_warning_message_box(title: str, message_widget: Widget, button_types: str = "ok", callback = None) -> None: if isinstance(message_widget, str): message_widget = Static(message_widget, markup=False) - for old_window in app.query("#message_box").nodes: - old_window.close() - - app.bell() - def handle_button(button): if callback: callback(button) @@ -318,4 +312,4 @@ def warning_message_box(app, title: str, message_widget: Widget, button_types: s ) ) ) - app.mount(window) + return window