Multi-line tooltip for pydot chart

I would like to add a multi-line tool for nodes in a graph that I generate using pydot. That's what I'm doing:

node = pydot.Node('abc', style='filled', fillcolor='#CCFF00', fontsize=12) txt = 'foo' + '\n' + 'test' node.set_tooltip(txt) 

The tool I see looks like "foo \ ntest"

I would appreciate any help.

Thanks Abhijit

+4
source share
1 answer

It seems that a new line character is supported for labels and names ( A new line in a node label in dots (graphic language) ), but tooltips are placed directly in the resulting HTML, which does not see "\ n" as a special character.

Using direct character codes is an alternative. (see Formatting and ASCII Control Codes )

 node = pydot.Node('abc', style='filled', fillcolor='#CCFF00', fontsize=12) # specify HTML Carriage Return (\r) and/or Line Feed (\n) characters directly txt = 'foo' + '
' + test' node.set_tooltip(txt) 

Or some simple preprocessing will allow you to save the form "\ n":

 node.set_tooltip(txt.replace('\n', '
')) 
+4
source

Source: https://habr.com/ru/post/1481961/


All Articles