pygui: added support for a details pane, can be toggled on/off, can be used to quickly view details for nodes or links
This commit is contained in:
parent
bb2ceaf993
commit
f582306bb9
12 changed files with 226 additions and 17 deletions
|
@ -7,8 +7,10 @@ from core.api.grpc import core_pb2
|
|||
from core.api.grpc.core_pb2 import Interface, Link
|
||||
from core.gui import themes
|
||||
from core.gui.dialogs.linkconfig import LinkConfigurationDialog
|
||||
from core.gui.frames.link import EdgeInfoFrame
|
||||
from core.gui.graph import tags
|
||||
from core.gui.nodeutils import NodeUtils
|
||||
from core.gui.utils import bandwidth_text
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from core.gui.graph.graph import CanvasGraph
|
||||
|
@ -57,18 +59,6 @@ def arc_edges(edges) -> None:
|
|||
edge.redraw()
|
||||
|
||||
|
||||
def bandwidth_label(bandwidth: int) -> str:
|
||||
size = {0: "bps", 1: "Kbps", 2: "Mbps", 3: "Gbps"}
|
||||
unit = 1000
|
||||
i = 0
|
||||
while bandwidth > unit:
|
||||
bandwidth /= unit
|
||||
i += 1
|
||||
if i == 3:
|
||||
break
|
||||
return f"{bandwidth} {size[i]}"
|
||||
|
||||
|
||||
class Edge:
|
||||
tag: str = tags.EDGE
|
||||
|
||||
|
@ -295,6 +285,7 @@ class CanvasEdge(Edge):
|
|||
|
||||
def set_binding(self) -> None:
|
||||
self.canvas.tag_bind(self.id, "<ButtonRelease-3>", self.show_context)
|
||||
self.canvas.tag_bind(self.id, "<Button-1>", self.show_info)
|
||||
|
||||
def set_link(self, link: Link) -> None:
|
||||
self.link = link
|
||||
|
@ -396,6 +387,9 @@ class CanvasEdge(Edge):
|
|||
self.middle_label = None
|
||||
self.canvas.itemconfig(self.id, fill=self.color, width=self.scaled_width())
|
||||
|
||||
def show_info(self, _event: tk.Event) -> None:
|
||||
self.canvas.app.display_info(EdgeInfoFrame, app=self.canvas.app, edge=self)
|
||||
|
||||
def show_context(self, event: tk.Event) -> None:
|
||||
state = tk.DISABLED if self.canvas.core.is_runtime() else tk.NORMAL
|
||||
self.context.entryconfigure(1, state=state)
|
||||
|
@ -413,7 +407,7 @@ class CanvasEdge(Edge):
|
|||
lines = []
|
||||
bandwidth = options.bandwidth
|
||||
if bandwidth > 0:
|
||||
lines.append(bandwidth_label(bandwidth))
|
||||
lines.append(bandwidth_text(bandwidth))
|
||||
delay = options.delay
|
||||
jitter = options.jitter
|
||||
if delay > 0 and jitter > 0:
|
||||
|
|
|
@ -715,6 +715,7 @@ class CanvasGraph(tk.Canvas):
|
|||
logging.debug("press delete key")
|
||||
if not self.app.core.is_runtime():
|
||||
self.delete_selected_objects()
|
||||
self.app.default_info()
|
||||
else:
|
||||
logging.debug("node deletion is disabled during runtime state")
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ from core.gui.dialogs.nodeconfig import NodeConfigDialog
|
|||
from core.gui.dialogs.nodeconfigservice import NodeConfigServiceDialog
|
||||
from core.gui.dialogs.nodeservice import NodeServiceDialog
|
||||
from core.gui.dialogs.wlanconfig import WlanConfigDialog
|
||||
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
|
||||
|
@ -80,6 +81,7 @@ class CanvasNode:
|
|||
self.canvas.tag_bind(self.id, "<Enter>", self.on_enter)
|
||||
self.canvas.tag_bind(self.id, "<Leave>", self.on_leave)
|
||||
self.canvas.tag_bind(self.id, "<ButtonRelease-3>", self.show_context)
|
||||
self.canvas.tag_bind(self.id, "<Button-1>", self.show_info)
|
||||
|
||||
def delete(self) -> None:
|
||||
logging.debug("Delete canvas node for %s", self.core_node)
|
||||
|
@ -195,6 +197,9 @@ class CanvasNode:
|
|||
else:
|
||||
self.show_config()
|
||||
|
||||
def show_info(self, _event: tk.Event) -> None:
|
||||
self.app.display_info(NodeInfoFrame, app=self.app, canvas_node=self)
|
||||
|
||||
def show_context(self, event: tk.Event) -> None:
|
||||
# clear existing menu
|
||||
self.context.delete(0, tk.END)
|
||||
|
@ -262,6 +267,7 @@ class CanvasNode:
|
|||
|
||||
def click_unlink(self, edge: CanvasEdge) -> None:
|
||||
self.canvas.delete_edge(edge)
|
||||
self.app.default_info()
|
||||
|
||||
def canvas_delete(self) -> None:
|
||||
self.canvas.clear_selection()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue