Welcome to yEd Q&A!
Here you can ask questions and receive answers from other members of the community and yEd developers. And you can tell us your most wanted feature requests.

Categories

Create Diagram From Python

+1 vote

It is possible to create a diagram from Python I have been analyzing the code of a .graphml to write a file from Python with this structure, however all my attempts have not been so successful. You will have something with this (Manual or examples).?

in Help by (190 points)

1 Answer

0 votes
 
Best answer
It should definitely be possible to create a .graphml file using some Python code, however, there is no such example / manual that describes this, I'm afraid.
by [yWorks] (23.7k points)
selected by
For people who come to this Post, I have found the solution and it was possible to create drawings from Python using a library called PYYED.

https://github.com/jamesscottbrown/pyyed

Python Console

from pyyed import *

g = pyyed.Graph()

g.add_node('foo', font_family="Zapfino")
g.add_node('foo2', shape="roundrectangle", font_style="bolditalic", underlined_text="true")

g.add_edge('foo1', 'foo2')
g.add_node('abc', font_size="72", height="100")

g.add_node('bar', label="Multi\nline\ntext")
g.add_node('foobar', label="""Multi
Line
Text!""")

#print g.get_graph()
z = g.get_graph()

print z


new_config_file = open("Ejemplo3" +'.graphml','w')
new_config_file.write(z)
new_config_file.close()
This needs to be changed.  The import call should be:
import pyyed
NOT
from pyyed import *

If you do this this code will generate graphml file to use in yEd software as an example
Legal Disclosure | Privacy Policy
...