I have a homework assignment where I need to generate a PDF file containing a tree image using Python 3 and LaTeX's tikz
package. It'd be really helpful if someone has a simple sample code.
I need to know how to create a child node.
from pylatex import (Document, TikZ, TikZNode, TikZDraw,TikZCoordinate,TikZUserPath, TikZOptions)
doc = Document()
# add our sample drawings
with doc.create(TikZ()) as pic:
node_kwargs = {'align': 'center', 'shape' : 'circle','minimum size': '50pt', 'fill': 'black!20'}
# create our test node
box = TikZNode(text='My block',
handle='box',
options=TikZOptions('draw',
'rounded corners',
**node_kwargs))
n_kw = {'shape' : 'circle',
'minimum size': '50pt',
'fill': 'black!20'}
#I DONT KNOW HOW TO PUT A CHILD NODE !!
box.child = TikZNode(text='My block 2',
handle='box2',
options=TikZOptions('draw',
'rounded corners',
**node_kwargs))
pic.append(box)
pic.append(box.child)
doc.generate_pdf('tikzdraw', clean_tex=False)