replace tkinter errormessage with custom create error dialog
This commit is contained in:
parent
9216683902
commit
0407645061
15 changed files with 132 additions and 56 deletions
|
@ -1,12 +1,32 @@
|
|||
from tkinter import messagebox
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from core.gui.dialogs.dialog import Dialog
|
||||
from core.gui.widgets import CodeText
|
||||
|
||||
if TYPE_CHECKING:
|
||||
import grpc
|
||||
from core.gui.app import Application
|
||||
|
||||
|
||||
def show_grpc_error(e: "grpc.RpcError"):
|
||||
class ErrorDialog(Dialog):
|
||||
def __init__(self, master, app: "Application", title: str, details: str):
|
||||
super().__init__(master, app, title, modal=True)
|
||||
self.error_message = None
|
||||
self.details = details
|
||||
self.draw()
|
||||
|
||||
def draw(self):
|
||||
self.top.columnconfigure(0, weight=1)
|
||||
self.top.rowconfigure(0, weight=1)
|
||||
self.error_message = CodeText(self.top)
|
||||
self.error_message.text.insert("1.0", self.details)
|
||||
self.error_message.text.config(state="disabled")
|
||||
self.error_message.grid(row=0, column=0, sticky="nsew")
|
||||
|
||||
|
||||
def show_grpc_error(e: "grpc.RpcError", master, app: "Application"):
|
||||
title = [x.capitalize() for x in e.code().name.lower().split("_")]
|
||||
title = " ".join(title)
|
||||
title = f"GRPC {title}"
|
||||
messagebox.showerror(title, e.details())
|
||||
dialog = ErrorDialog(master, app, title, e.details())
|
||||
dialog.show()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue