From 8266f7d84c9458a506aa037364fee2e9f300c92c Mon Sep 17 00:00:00 2001 From: Bruno Meneguello <1322552+bkmeneguello@users.noreply.github.com> Date: Wed, 30 Dec 2020 11:03:57 -0300 Subject: [PATCH] Set Node tooltip to the Class name --- diagrams/__init__.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/diagrams/__init__.py b/diagrams/__init__.py index ca84e75c..6ac564f5 100644 --- a/diagrams/__init__.py +++ b/diagrams/__init__.py @@ -324,12 +324,14 @@ class Node(_Cluster): # that label being spanned between icon image and white space. # Increase the height by the number of new lines included in the label. padding = 0.4 * (label.count('\n')) - icon = self._load_icon() + icon_path = self._load_icon() self._attrs = { "shape": "none", "height": str(self._height + padding), - "image": icon, - } if icon else {} + "image": icon_path, + } if icon_path else {} + + self._attrs['tooltip'] = (icon if icon else self).__class__.__name__ # fmt: on self._attrs.update(attrs) @@ -343,6 +345,7 @@ class Node(_Cluster): # Set attributes. for k, v in self._default_graph_attrs.items(): self.dot.graph_attr[k] = v + self.dot.graph_attr['tooltip'] = self._attrs['tooltip'] icon = self._load_icon() if icon: @@ -536,6 +539,7 @@ class Edge: # Graphviz complaining about using label for edges, so replace it with xlabel. # Update: xlabel option causes the misaligned label position: https://github.com/mingrammer/diagrams/issues/83 self._attrs["label"] = label + self._attrs["tooltip"] = label if color: self._attrs["color"] = color if style: