From 53931ebebedda44904f7bb27f94589a569f853d5 Mon Sep 17 00:00:00 2001 From: Mateo Date: Mon, 21 Mar 2022 23:13:53 -0300 Subject: [PATCH] Node and label distance correct with redraw Related to https://github.com/coreemu/core/issues/673 --- daemon/core/gui/graph/node.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/daemon/core/gui/graph/node.py b/daemon/core/gui/graph/node.py index 1de7319f7..4e3317134 100644 --- a/daemon/core/gui/graph/node.py +++ b/daemon/core/gui/graph/node.py @@ -137,6 +137,7 @@ def redraw(self) -> None: self.canvas.itemconfig(self.id, image=self.image) label = self.get_label() self.canvas.itemconfig(self.text_id, text=label) + self.scale_text() for edge in self.edges: edge.redraw() @@ -146,9 +147,10 @@ def _get_label_y(self) -> int: def scale_text(self) -> None: text_bound = self.canvas.bbox(self.text_id) - prev_y = (text_bound[3] + text_bound[1]) / 2 - new_y = self._get_label_y() - self.canvas.move(self.text_id, 0, new_y - prev_y) + if text_bound: + prev_y = (text_bound[3] + text_bound[1]) / 2 + new_y = self._get_label_y() + self.canvas.move(self.text_id, 0, new_y - prev_y) def move(self, x: float, y: float) -> None: x, y = self.canvas.get_scaled_coords(x, y)