grpc: update node events to include icon, pygui: updated handling node events to update icon when there is a change
This commit is contained in:
parent
8004be6e7c
commit
b89a19a18e
3 changed files with 14 additions and 2 deletions
|
@ -32,6 +32,7 @@ def handle_node_event(node_data: NodeData) -> core_pb2.Event:
|
|||
id=node.id,
|
||||
name=node.name,
|
||||
model=node.type,
|
||||
icon=node.icon,
|
||||
position=position,
|
||||
geo=geo,
|
||||
services=services,
|
||||
|
|
|
@ -241,6 +241,8 @@ class CoreClient:
|
|||
x = node.position.x
|
||||
y = node.position.y
|
||||
canvas_node.move(x, y)
|
||||
if node.icon and node.icon != canvas_node.core_node.icon:
|
||||
canvas_node.update_icon(node.icon)
|
||||
elif event.message_type == MessageType.DELETE:
|
||||
canvas_node = self.canvas_nodes[node.id]
|
||||
self.app.canvas.clear_selection()
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
import functools
|
||||
import logging
|
||||
import tkinter as tk
|
||||
from pathlib import Path
|
||||
from typing import TYPE_CHECKING, Dict, List, Set
|
||||
|
||||
import grpc
|
||||
from PIL.ImageTk import PhotoImage
|
||||
|
||||
from core.gui import themes
|
||||
from core.gui import nodeutils, themes
|
||||
from core.gui.dialogs.emaneconfig import EmaneConfigDialog
|
||||
from core.gui.dialogs.mobilityconfig import MobilityConfigDialog
|
||||
from core.gui.dialogs.nodeconfig import NodeConfigDialog
|
||||
|
@ -17,7 +18,7 @@ from core.gui.frames.node import NodeInfoFrame
|
|||
from core.gui.graph import tags
|
||||
from core.gui.graph.edges import CanvasEdge, CanvasWirelessEdge
|
||||
from core.gui.graph.tooltip import CanvasTooltip
|
||||
from core.gui.images import ImageEnum
|
||||
from core.gui.images import ImageEnum, Images
|
||||
from core.gui.nodeutils import ANTENNA_SIZE, NodeUtils
|
||||
from core.gui.wrappers import Interface, Node, NodeType
|
||||
|
||||
|
@ -347,3 +348,11 @@ class CanvasNode:
|
|||
dx = node_x - 16 + (i * 8 * self.app.app_scale) - x
|
||||
dy = node_y - int(23 * self.app.app_scale) - y
|
||||
self.canvas.move(antenna_id, dx, dy)
|
||||
|
||||
def update_icon(self, icon_path: str) -> None:
|
||||
if not Path(icon_path).exists():
|
||||
logging.error(f"node icon does not exist: {icon_path}")
|
||||
return
|
||||
self.core_node.icon = icon_path
|
||||
self.image = Images.create(icon_path, nodeutils.ICON_SIZE)
|
||||
self.canvas.itemconfig(self.id, image=self.image)
|
||||
|
|
Loading…
Reference in a new issue