pygui: added simple error dialog call to app, also added blocking option for some error dialogs when needed

This commit is contained in:
Blake Harnden 2021-02-19 10:35:59 -08:00
parent 2387812a76
commit b163b06596
4 changed files with 37 additions and 21 deletions

View file

@ -13,9 +13,11 @@ if TYPE_CHECKING:
class ErrorDialog(Dialog):
def __init__(self, app: "Application", title: str, details: str) -> None:
super().__init__(app, "CORE Exception")
self.title: str = title
def __init__(
self, app: "Application", title: str, message: str, details: str
) -> None:
super().__init__(app, title)
self.message: str = message
self.details: str = details
self.error_message: Optional[CodeText] = None
self.draw()
@ -25,13 +27,13 @@ class ErrorDialog(Dialog):
self.top.rowconfigure(1, weight=1)
image = images.from_enum(ImageEnum.ERROR, width=images.ERROR_SIZE)
label = ttk.Label(
self.top, text=self.title, image=image, compound=tk.LEFT, anchor=tk.CENTER
self.top, text=self.message, image=image, compound=tk.LEFT, anchor=tk.CENTER
)
label.image = image
label.grid(sticky=tk.EW, pady=PADY)
label.grid(sticky=tk.W, pady=PADY)
self.error_message = CodeText(self.top)
self.error_message.text.insert("1.0", self.details)
self.error_message.text.config(state=tk.DISABLED)
self.error_message.grid(sticky=tk.NSEW, pady=PADY)
self.error_message.grid(sticky=tk.EW, pady=PADY)
button = ttk.Button(self.top, text="Close", command=lambda: self.destroy())
button.grid(sticky=tk.EW)