pygui: added view option to toggle wireless edges

This commit is contained in:
Blake Harnden 2020-08-04 16:20:51 -07:00
parent e2b3a2dc6d
commit cd0351c818
3 changed files with 12 additions and 3 deletions

View file

@ -110,7 +110,9 @@ class Edge:
arc_y = (perp_m * arc_x) + b
return arc_x, arc_y
def draw(self, src_pos: Tuple[float, float], dst_pos: Tuple[float, float]) -> None:
def draw(
self, src_pos: Tuple[float, float], dst_pos: Tuple[float, float], state: str
) -> None:
arc_pos = self._get_arcpoint(src_pos, dst_pos)
self.id = self.canvas.create_line(
*src_pos,
@ -120,6 +122,7 @@ class Edge:
tags=self.tag,
width=self.scaled_width(),
fill=self.color,
state=state,
)
def redraw(self) -> None:
@ -249,7 +252,7 @@ class CanvasWirelessEdge(Edge):
self.width: float = WIRELESS_WIDTH
color = link.color if link.color else WIRELESS_COLOR
self.color: str = color
self.draw(src_pos, dst_pos)
self.draw(src_pos, dst_pos, self.canvas.show_wireless.state())
if link.label:
self.middle_label_text(link.label)
self.set_binding()
@ -286,7 +289,7 @@ class CanvasEdge(Edge):
self.link: Optional[Link] = None
self.asymmetric_link: Optional[Link] = None
self.throughput: Optional[float] = None
self.draw(src_pos, dst_pos)
self.draw(src_pos, dst_pos, tk.NORMAL)
self.set_binding()
self.context: tk.Menu = tk.Menu(self.canvas)
self.create_context()

View file

@ -97,6 +97,7 @@ class CanvasGraph(tk.Canvas):
# drawing related
self.show_node_labels: ShowVar = ShowVar(self, tags.NODE_LABEL, value=True)
self.show_link_labels: ShowVar = ShowVar(self, tags.LINK_LABEL, value=True)
self.show_wireless: ShowVar = ShowVar(self, tags.WIRELESS_EDGE, value=True)
self.show_grid: ShowVar = ShowVar(self, tags.GRIDLINE, value=True)
self.show_annotations: ShowVar = ShowVar(self, tags.ANNOTATION, value=True)
self.show_iface_names: BooleanVar = BooleanVar(value=False)

View file

@ -167,6 +167,11 @@ class Menubar(tk.Menu):
command=self.canvas.show_link_labels.click_handler,
variable=self.canvas.show_link_labels,
)
menu.add_checkbutton(
label="Wireless Links",
command=self.canvas.show_wireless.click_handler,
variable=self.canvas.show_wireless,
)
menu.add_checkbutton(
label="Annotations",
command=self.canvas.show_annotations.click_handler,