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.model = f"emane_{model}"
|
||||||
self.interface = interface
|
self.interface = interface
|
||||||
self.config_frame = None
|
self.config_frame = None
|
||||||
self.error = False
|
self.has_error = False
|
||||||
try:
|
try:
|
||||||
self.config = self.app.core.get_emane_model_config(
|
self.config = self.app.core.get_emane_model_config(
|
||||||
self.node.id, self.model, self.interface
|
self.node.id, self.model, self.interface
|
||||||
)
|
)
|
||||||
|
self.draw()
|
||||||
except grpc.RpcError as e:
|
except grpc.RpcError as e:
|
||||||
show_grpc_error(e, self.app, self.app)
|
show_grpc_error(e, self.app, self.app)
|
||||||
self.error = True
|
self.has_error = True
|
||||||
self.destroy()
|
self.destroy()
|
||||||
if not self.error:
|
|
||||||
self.draw()
|
|
||||||
|
|
||||||
def draw(self):
|
def draw(self):
|
||||||
self.top.columnconfigure(0, weight=1)
|
self.top.columnconfigure(0, weight=1)
|
||||||
|
@ -228,7 +227,7 @@ class EmaneConfigDialog(Dialog):
|
||||||
dialog = EmaneModelDialog(
|
dialog = EmaneModelDialog(
|
||||||
self, self.app, self.canvas_node.core_node, model_name
|
self, self.app, self.canvas_node.core_node, model_name
|
||||||
)
|
)
|
||||||
if not dialog.error:
|
if not dialog.has_error:
|
||||||
dialog.show()
|
dialog.show()
|
||||||
|
|
||||||
def emane_model_change(self, event: tk.Event):
|
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 error occurred when creating ServiceConfigDialog, don't show the dialog
|
||||||
if not dialog.error:
|
if not dialog.has_error:
|
||||||
dialog.show()
|
dialog.show()
|
||||||
else:
|
else:
|
||||||
dialog.destroy()
|
dialog.destroy()
|
||||||
|
|
|
@ -65,15 +65,13 @@ class ServiceConfigDialog(Dialog):
|
||||||
self.temp_service_files = {}
|
self.temp_service_files = {}
|
||||||
self.modified_files = set()
|
self.modified_files = set()
|
||||||
|
|
||||||
self.error = True
|
self.has_error = False
|
||||||
|
|
||||||
load_result = self.load()
|
self.load()
|
||||||
if load_result:
|
if not self.has_error:
|
||||||
self.draw()
|
self.draw()
|
||||||
self.error = False
|
|
||||||
|
|
||||||
def load(self) -> bool:
|
def load(self) -> bool:
|
||||||
result = False
|
|
||||||
try:
|
try:
|
||||||
self.app.core.create_nodes_and_links()
|
self.app.core.create_nodes_and_links()
|
||||||
default_config = self.app.core.get_node_service(
|
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():
|
for file, data in file_configs[self.node_id][self.service_name].items():
|
||||||
self.temp_service_files[file] = data
|
self.temp_service_files[file] = data
|
||||||
result = True
|
|
||||||
except grpc.RpcError as e:
|
except grpc.RpcError as e:
|
||||||
|
self.has_error = True
|
||||||
show_grpc_error(e, self.master, self.app)
|
show_grpc_error(e, self.master, self.app)
|
||||||
return result
|
|
||||||
|
|
||||||
def draw(self):
|
def draw(self):
|
||||||
self.top.columnconfigure(0, weight=1)
|
self.top.columnconfigure(0, weight=1)
|
||||||
|
|
|
@ -25,9 +25,9 @@ class SessionsDialog(Dialog):
|
||||||
self.selected = False
|
self.selected = False
|
||||||
self.selected_id = None
|
self.selected_id = None
|
||||||
self.tree = None
|
self.tree = None
|
||||||
self.error = False
|
self.has_error = False
|
||||||
self.sessions = self.get_sessions()
|
self.sessions = self.get_sessions()
|
||||||
if not self.error:
|
if not self.has_error:
|
||||||
self.draw()
|
self.draw()
|
||||||
|
|
||||||
def get_sessions(self) -> Iterable[core_pb2.SessionSummary]:
|
def get_sessions(self) -> Iterable[core_pb2.SessionSummary]:
|
||||||
|
@ -37,7 +37,7 @@ class SessionsDialog(Dialog):
|
||||||
return response.sessions
|
return response.sessions
|
||||||
except grpc.RpcError as e:
|
except grpc.RpcError as e:
|
||||||
show_grpc_error(e, self.app, self.app)
|
show_grpc_error(e, self.app, self.app)
|
||||||
self.error = True
|
self.has_error = True
|
||||||
self.destroy()
|
self.destroy()
|
||||||
|
|
||||||
def draw(self):
|
def draw(self):
|
||||||
|
|
|
@ -27,13 +27,13 @@ class WlanConfigDialog(Dialog):
|
||||||
self.canvas_node = canvas_node
|
self.canvas_node = canvas_node
|
||||||
self.node = canvas_node.core_node
|
self.node = canvas_node.core_node
|
||||||
self.config_frame = None
|
self.config_frame = None
|
||||||
self.error = False
|
self.has_error = False
|
||||||
try:
|
try:
|
||||||
self.config = self.app.core.get_wlan_config(self.node.id)
|
self.config = self.app.core.get_wlan_config(self.node.id)
|
||||||
self.draw()
|
self.draw()
|
||||||
except grpc.RpcError as e:
|
except grpc.RpcError as e:
|
||||||
show_grpc_error(e, self.app, self.app)
|
show_grpc_error(e, self.app, self.app)
|
||||||
self.error = True
|
self.has_error = True
|
||||||
self.destroy()
|
self.destroy()
|
||||||
|
|
||||||
def draw(self):
|
def draw(self):
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
|
from tkinter import ttk
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
from core.gui.dialogs.dialog import Dialog
|
from core.gui.dialogs.dialog import Dialog
|
||||||
|
from core.gui.images import ImageEnum, Images
|
||||||
from core.gui.widgets import CodeText
|
from core.gui.widgets import CodeText
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
|
@ -18,10 +20,14 @@ class ErrorDialog(Dialog):
|
||||||
def draw(self):
|
def draw(self):
|
||||||
self.top.columnconfigure(0, weight=1)
|
self.top.columnconfigure(0, weight=1)
|
||||||
self.top.rowconfigure(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 = CodeText(self.top)
|
||||||
self.error_message.text.insert("1.0", self.details)
|
self.error_message.text.insert("1.0", self.details)
|
||||||
self.error_message.text.config(state="disabled")
|
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"):
|
def show_grpc_error(e: "grpc.RpcError", master, app: "Application"):
|
||||||
|
|
|
@ -240,7 +240,7 @@ class CanvasNode:
|
||||||
def show_wlan_config(self):
|
def show_wlan_config(self):
|
||||||
self.canvas.context = None
|
self.canvas.context = None
|
||||||
dialog = WlanConfigDialog(self.app, self.app, self)
|
dialog = WlanConfigDialog(self.app, self.app, self)
|
||||||
if not dialog.error:
|
if not dialog.has_error:
|
||||||
dialog.show()
|
dialog.show()
|
||||||
|
|
||||||
def show_mobility_config(self):
|
def show_mobility_config(self):
|
||||||
|
|
|
@ -89,3 +89,4 @@ class ImageEnum(Enum):
|
||||||
DELETE = "delete"
|
DELETE = "delete"
|
||||||
SHUTDOWN = "shutdown"
|
SHUTDOWN = "shutdown"
|
||||||
CANCEL = "cancel"
|
CANCEL = "cancel"
|
||||||
|
ERROR = "error"
|
||||||
|
|
Loading…
Add table
Reference in a new issue