change some variable names to be more informative, add an image to error dialog
This commit is contained in:
parent
0407645061
commit
ee0c63e4a1
9 changed files with 23 additions and 20 deletions
BIN
daemon/core/gui/data/icons/error.png
Normal file
BIN
daemon/core/gui/data/icons/error.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.2 KiB |
|
@ -65,17 +65,16 @@ class EmaneModelDialog(Dialog):
|
|||
self.model = f"emane_{model}"
|
||||
self.interface = interface
|
||||
self.config_frame = None
|
||||
self.error = False
|
||||
self.has_error = False
|
||||
try:
|
||||
self.config = self.app.core.get_emane_model_config(
|
||||
self.node.id, self.model, self.interface
|
||||
)
|
||||
self.draw()
|
||||
except grpc.RpcError as e:
|
||||
show_grpc_error(e, self.app, self.app)
|
||||
self.error = True
|
||||
self.has_error = True
|
||||
self.destroy()
|
||||
if not self.error:
|
||||
self.draw()
|
||||
|
||||
def draw(self):
|
||||
self.top.columnconfigure(0, weight=1)
|
||||
|
@ -228,7 +227,7 @@ class EmaneConfigDialog(Dialog):
|
|||
dialog = EmaneModelDialog(
|
||||
self, self.app, self.canvas_node.core_node, model_name
|
||||
)
|
||||
if not dialog.error:
|
||||
if not dialog.has_error:
|
||||
dialog.show()
|
||||
|
||||
def emane_model_change(self, event: tk.Event):
|
||||
|
|
|
@ -142,7 +142,7 @@ class NodeServiceDialog(Dialog):
|
|||
)
|
||||
|
||||
# if error occurred when creating ServiceConfigDialog, don't show the dialog
|
||||
if not dialog.error:
|
||||
if not dialog.has_error:
|
||||
dialog.show()
|
||||
else:
|
||||
dialog.destroy()
|
||||
|
|
|
@ -65,15 +65,13 @@ class ServiceConfigDialog(Dialog):
|
|||
self.temp_service_files = {}
|
||||
self.modified_files = set()
|
||||
|
||||
self.error = True
|
||||
self.has_error = False
|
||||
|
||||
load_result = self.load()
|
||||
if load_result:
|
||||
self.load()
|
||||
if not self.has_error:
|
||||
self.draw()
|
||||
self.error = False
|
||||
|
||||
def load(self) -> bool:
|
||||
result = False
|
||||
try:
|
||||
self.app.core.create_nodes_and_links()
|
||||
default_config = self.app.core.get_node_service(
|
||||
|
@ -114,10 +112,9 @@ class ServiceConfigDialog(Dialog):
|
|||
):
|
||||
for file, data in file_configs[self.node_id][self.service_name].items():
|
||||
self.temp_service_files[file] = data
|
||||
result = True
|
||||
except grpc.RpcError as e:
|
||||
self.has_error = True
|
||||
show_grpc_error(e, self.master, self.app)
|
||||
return result
|
||||
|
||||
def draw(self):
|
||||
self.top.columnconfigure(0, weight=1)
|
||||
|
|
|
@ -25,9 +25,9 @@ class SessionsDialog(Dialog):
|
|||
self.selected = False
|
||||
self.selected_id = None
|
||||
self.tree = None
|
||||
self.error = False
|
||||
self.has_error = False
|
||||
self.sessions = self.get_sessions()
|
||||
if not self.error:
|
||||
if not self.has_error:
|
||||
self.draw()
|
||||
|
||||
def get_sessions(self) -> Iterable[core_pb2.SessionSummary]:
|
||||
|
@ -37,7 +37,7 @@ class SessionsDialog(Dialog):
|
|||
return response.sessions
|
||||
except grpc.RpcError as e:
|
||||
show_grpc_error(e, self.app, self.app)
|
||||
self.error = True
|
||||
self.has_error = True
|
||||
self.destroy()
|
||||
|
||||
def draw(self):
|
||||
|
|
|
@ -27,13 +27,13 @@ class WlanConfigDialog(Dialog):
|
|||
self.canvas_node = canvas_node
|
||||
self.node = canvas_node.core_node
|
||||
self.config_frame = None
|
||||
self.error = False
|
||||
self.has_error = False
|
||||
try:
|
||||
self.config = self.app.core.get_wlan_config(self.node.id)
|
||||
self.draw()
|
||||
except grpc.RpcError as e:
|
||||
show_grpc_error(e, self.app, self.app)
|
||||
self.error = True
|
||||
self.has_error = True
|
||||
self.destroy()
|
||||
|
||||
def draw(self):
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
from tkinter import ttk
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from core.gui.dialogs.dialog import Dialog
|
||||
from core.gui.images import ImageEnum, Images
|
||||
from core.gui.widgets import CodeText
|
||||
|
||||
if TYPE_CHECKING:
|
||||
|
@ -18,10 +20,14 @@ class ErrorDialog(Dialog):
|
|||
def draw(self):
|
||||
self.top.columnconfigure(0, weight=1)
|
||||
self.top.rowconfigure(0, weight=1)
|
||||
image = Images.get(ImageEnum.ERROR, 36)
|
||||
label = ttk.Label(self.top, image=image)
|
||||
label.image = image
|
||||
label.grid(row=0, column=0)
|
||||
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")
|
||||
self.error_message.grid(row=1, column=0, sticky="nsew")
|
||||
|
||||
|
||||
def show_grpc_error(e: "grpc.RpcError", master, app: "Application"):
|
||||
|
|
|
@ -240,7 +240,7 @@ class CanvasNode:
|
|||
def show_wlan_config(self):
|
||||
self.canvas.context = None
|
||||
dialog = WlanConfigDialog(self.app, self.app, self)
|
||||
if not dialog.error:
|
||||
if not dialog.has_error:
|
||||
dialog.show()
|
||||
|
||||
def show_mobility_config(self):
|
||||
|
|
|
@ -89,3 +89,4 @@ class ImageEnum(Enum):
|
|||
DELETE = "delete"
|
||||
SHUTDOWN = "shutdown"
|
||||
CANCEL = "cancel"
|
||||
ERROR = "error"
|
||||
|
|
Loading…
Reference in a new issue