示例#1
0
from ascii_tree import make_and_print_tree
from node_types import NTreeNode
'''
Now make it ever wider, such that it can't fit on the screen.
This will print multiple pages now
'''
root1 = NTreeNode('onomatopaie' * 10)
root1.children = [NTreeNode(f'lorem ipsum dolor...{i}') for i in range(10)]
print("Printing root1...")
make_and_print_tree(root1, lambda node: node.val, lambda node: node.children)
'''
Notice how the object is split over multiple pages.
Also observer that the parent is duplicated in both pages.
This is done to make the graph more readable.
The splitting algorithm will split along any level of
the tree.
'''
示例#2
0
from ascii_tree import make_and_print_tree, update_param
from node_types import NTreeNode

root = NTreeNode('Lorem ipsum dolor sit amet')
root.children = [
    NTreeNode('consectetur adipiscing elit.'),
    NTreeNode('Etiam laoreet congue')
]
root.children[0].children = [
    NTreeNode('Pellentesque finibus metus eget'),
    NTreeNode('ante aliquet ullamcorper')
]
root.children[1].children = [
    NTreeNode('Morbi porta, diam at imperdiet venenatis'),
    NTreeNode('neque eros bibendum tortor, quis')
]

update_param('screen_width', 120)
update_param('box_max_width', 20)
update_param('charset', 'ascii')
make_and_print_tree(root, lambda n: n.val, lambda n: n.children)