pygui: clear throughput labels when disabling throughput

This commit is contained in:
Blake Harnden 2020-06-23 14:48:27 -07:00
parent 7215f852b8
commit 60d9fe2026
3 changed files with 10 additions and 2 deletions

View file

@ -221,6 +221,7 @@ class CoreClient:
if self.handling_throughputs:
self.handling_throughputs.cancel()
self.handling_throughputs = None
self.app.canvas.clear_throughputs()
def cancel_events(self) -> None:
if self.handling_events:

View file

@ -145,6 +145,10 @@ class Edge:
else:
self.canvas.itemconfig(self.middle_label, text=text)
def clear_middle_label(self) -> None:
self.canvas.delete(self.middle_label)
self.middle_label = None
def node_label_positions(self) -> Tuple[Tuple[float, float], Tuple[float, float]]:
src_x, src_y, _, _, dst_x, dst_y = self.canvas.coords(self.id)
v1 = dst_x - src_x
@ -216,11 +220,10 @@ class Edge:
logging.debug("deleting canvas edge, id: %s", self.id)
self.canvas.delete(self.id)
self.canvas.delete(self.src_label)
self.canvas.delete(self.middle_label)
self.canvas.delete(self.dst_label)
self.clear_middle_label()
self.id = None
self.src_label = None
self.middle_label = None
self.dst_label = None

View file

@ -997,6 +997,10 @@ class CanvasGraph(tk.Canvas):
)
self.tag_raise(tags.NODE)
def clear_throughputs(self) -> None:
for edge in self.edges.values():
edge.clear_middle_label()
def scale_graph(self) -> None:
for nid, canvas_node in self.nodes.items():
img = None