small updates to new gui exception dialog, fixed error checking and setting interface mac addresses
This commit is contained in:
parent
595e77a1ef
commit
6b5cd95ac2
5 changed files with 49 additions and 20 deletions
|
@ -1,36 +1,49 @@
|
|||
from tkinter import ttk
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import grpc
|
||||
|
||||
from core.gui.dialogs.dialog import Dialog
|
||||
from core.gui.images import ImageEnum, Images
|
||||
from core.gui.themes import FRAME_PAD, PADX, PADY
|
||||
from core.gui.widgets import CodeText
|
||||
|
||||
if TYPE_CHECKING:
|
||||
import grpc
|
||||
from core.gui.app import Application
|
||||
|
||||
|
||||
class ErrorDialog(Dialog):
|
||||
def __init__(self, master, app: "Application", title: str, details: str):
|
||||
super().__init__(master, app, title, modal=True)
|
||||
self.error_message = None
|
||||
def __init__(self, master, app: "Application", title: str, details: str) -> None:
|
||||
super().__init__(master, app, "CORE Exception", modal=True)
|
||||
self.title = title
|
||||
self.details = details
|
||||
self.error_message = None
|
||||
self.draw()
|
||||
|
||||
def draw(self):
|
||||
def draw(self) -> None:
|
||||
self.top.columnconfigure(0, weight=1)
|
||||
self.top.rowconfigure(0, weight=1)
|
||||
self.top.rowconfigure(1, weight=1)
|
||||
|
||||
frame = ttk.Frame(self.top, padding=FRAME_PAD)
|
||||
frame.grid(pady=PADY, sticky="ew")
|
||||
frame.columnconfigure(1, weight=1)
|
||||
image = Images.get(ImageEnum.ERROR, 36)
|
||||
label = ttk.Label(self.top, image=image)
|
||||
label = ttk.Label(frame, image=image)
|
||||
label.image = image
|
||||
label.grid(row=0, column=0)
|
||||
label.grid(row=0, column=0, padx=PADX)
|
||||
label = ttk.Label(frame, text=self.title)
|
||||
label.grid(row=0, column=1, sticky="ew")
|
||||
|
||||
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=1, column=0, sticky="nsew")
|
||||
self.error_message.grid(sticky="nsew", pady=PADY)
|
||||
|
||||
button = ttk.Button(self.top, text="Close", command=lambda: self.destroy())
|
||||
button.grid(sticky="ew")
|
||||
|
||||
|
||||
def show_grpc_error(e: "grpc.RpcError", master, app: "Application"):
|
||||
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}"
|
||||
|
@ -40,8 +53,6 @@ def show_grpc_error(e: "grpc.RpcError", master, app: "Application"):
|
|||
|
||||
def show_grpc_response_exceptions(class_name, exceptions, master, app: "Application"):
|
||||
title = f"Exceptions from {class_name}"
|
||||
detail = ""
|
||||
for e in exceptions:
|
||||
detail = detail + f"{e}\n"
|
||||
detail = "\n".join([str(x) for x in exceptions])
|
||||
dialog = ErrorDialog(master, app, title, detail)
|
||||
dialog.show()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue