Explorar el Código

Better handling of multiline Cluster labels

pull/407/head^2
Bruno Meneguello hace 3 años
padre
commit
070308c254
Se han modificado 1 ficheros con 6 adiciones y 4 borrados
  1. +6
    -4
      diagrams/__init__.py

+ 6
- 4
diagrams/__init__.py Ver fichero

@@ -346,10 +346,12 @@ class Node(_Cluster):

icon = self._load_icon()
if icon:
self.dot.graph_attr["label"] = '<<TABLE border="0"><TR>'\
'<TD fixedsize="true" width="' + str(self._icon_size) + '" height="' + str(self._icon_size) + '">'\
'<IMG SRC="' + icon + '"></IMG></TD>'\
'<TD>' + html.escape(self.label) + '</TD></TR></TABLE>>'
lines = iter(html.escape(self.label).split("\n"))
self.dot.graph_attr["label"] = '<<TABLE border="0"><TR>' +\
f'<TD fixedsize="true" width="{self._icon_size}" height="{self._icon_size}"><IMG SRC="{icon}"></IMG></TD>' +\
f'<TD align="left">{next(lines)}</TD></TR>' +\
''.join(f'<TR><TD colspan="2" align="left">{line}</TD></TR>' for line in lines) +\
'</TABLE>>'

if not self._validate_direction(self._direction):
raise ValueError(f'"{self._direction}" is not a valid direction')


Cargando…
Cancelar
Guardar