pygui: updates to show wireless edges in details panel, increased edge thickness to be the same as normal edges for selection to be easier
This commit is contained in:
parent
f4224d1b80
commit
eac941ce72
3 changed files with 74 additions and 9 deletions
|
@ -1,12 +1,26 @@
|
|||
import tkinter as tk
|
||||
from typing import TYPE_CHECKING
|
||||
from typing import TYPE_CHECKING, Optional
|
||||
|
||||
from core.api.grpc.core_pb2 import Interface
|
||||
from core.gui.frames.base import DetailsFrame, InfoFrameBase
|
||||
from core.gui.utils import bandwidth_text
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from core.gui.app import Application
|
||||
from core.gui.graph.edges import CanvasEdge
|
||||
from core.gui.graph.node import CanvasNode
|
||||
from core.gui.graph.edges import CanvasWirelessEdge
|
||||
|
||||
|
||||
def get_iface(canvas_node: "CanvasNode", net_id: int) -> Optional[Interface]:
|
||||
iface = None
|
||||
for edge in canvas_node.edges:
|
||||
link = edge.link
|
||||
if link.node1_id == net_id:
|
||||
iface = link.iface2
|
||||
elif link.node2_id == net_id:
|
||||
iface = link.iface1
|
||||
return iface
|
||||
|
||||
|
||||
class EdgeInfoFrame(InfoFrameBase):
|
||||
|
@ -56,3 +70,44 @@ class EdgeInfoFrame(InfoFrameBase):
|
|||
frame.add_detail("Jitter", f"\u00B1{options.jitter} us")
|
||||
frame.add_detail("Loss", f"{options.loss}%")
|
||||
frame.add_detail("Duplicate", f"{options.dup}%")
|
||||
|
||||
|
||||
class WirelessEdgeInfoFrame(InfoFrameBase):
|
||||
def __init__(
|
||||
self, master: tk.BaseWidget, app: "Application", edge: "CanvasWirelessEdge"
|
||||
) -> None:
|
||||
super().__init__(master, app)
|
||||
self.edge: "CanvasWirelessEdge" = edge
|
||||
|
||||
def draw(self) -> None:
|
||||
link = self.edge.link
|
||||
src_canvas_node = self.app.core.canvas_nodes[link.node1_id]
|
||||
src_node = src_canvas_node.core_node
|
||||
dst_canvas_node = self.app.core.canvas_nodes[link.node2_id]
|
||||
dst_node = dst_canvas_node.core_node
|
||||
|
||||
# find interface for each node connected to network
|
||||
net_id = link.network_id
|
||||
iface1 = get_iface(src_canvas_node, net_id)
|
||||
iface2 = get_iface(dst_canvas_node, net_id)
|
||||
|
||||
frame = DetailsFrame(self)
|
||||
frame.grid(sticky="ew")
|
||||
frame.add_detail("Source", src_node.name)
|
||||
if iface1:
|
||||
mac = iface1.mac if iface1.mac else "auto"
|
||||
frame.add_detail("MAC", mac)
|
||||
ip4 = f"{iface1.ip4}/{iface1.ip4_mask}" if iface1.ip4 else ""
|
||||
frame.add_detail("IP4", ip4)
|
||||
ip6 = f"{iface1.ip6}/{iface1.ip6_mask}" if iface1.ip6 else ""
|
||||
frame.add_detail("IP6", ip6)
|
||||
|
||||
frame.add_separator()
|
||||
frame.add_detail("Destination", dst_node.name)
|
||||
if iface2:
|
||||
mac = iface2.mac if iface2.mac else "auto"
|
||||
frame.add_detail("MAC", mac)
|
||||
ip4 = f"{iface2.ip4}/{iface2.ip4_mask}" if iface2.ip4 else ""
|
||||
frame.add_detail("IP4", ip4)
|
||||
ip6 = f"{iface2.ip6}/{iface2.ip6_mask}" if iface2.ip6 else ""
|
||||
frame.add_detail("IP6", ip6)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue