AharonSambol / PrettyPrintTree

Python library to print trees

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add a print image option

alibillalhammoud opened this issue · comments

I was wondering if it would be possible to add an option to print the tree to an image. With big trees working in the terminal becomes unruly even with max_depth setting.

Interesting idea, for now if you want you can simply use
return_instead_of_print=True
(and I recommend: color=None, border=True)
which will return a string reoresenting the tree instead of printing it
then write that string to a text file
(this doesnt work with json at the moment hopefully ill fix that today)

Hello @AharonSambol
This is a great tool. Thank you for developing this and responding to my issue!
I have tried the solution you proposed and it works, but the txt file does not show the pretty formatting that the terminal output does. In the past I have used this tool to create nice figures of trees, but I have to print to terminal then screen shot the output.

Glad you like it :)
Just to keep you updated: I now released a new version so that it'll work with json as well
As for the images - It's a great Idea and i'd like to do it but I don't really have time right now, but it'll be on my todo list
An aproach you could try is to take the string and use a library such as pillow to display it as an image, but before doing that removing all the places I've used ansi escepe sequences (for the background) and drawing the background based off that... but that probably wont be a small task...