mirror of
https://github.com/1j01/textual-paint.git
synced 2025-01-03 12:22:23 +03:00
Move bits of warning_message_box that need App back into App
This commit is contained in:
parent
37ff810616
commit
093a314d60
11
paint.py
11
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."""
|
||||
|
10
windows.py
10
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
|
||||
|
Loading…
Reference in New Issue
Block a user