Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tree: add render_node arg to __print_backend #1

Merged
merged 1 commit into from
May 8, 2024

Commits on May 8, 2024

  1. tree: add render_node arg to __print_backend

    This let us do inversion of control[1], passing in a callback function
    that gives more flexibility into how the node is rendered when using
    show() and save2file().
    
    **Example:**
    
    ```py
    def render_node(node):
      if node.level > 2:
        return node.my_property
      return node.some_other_property
    
    tree.show(render_node=render_node)
    ```
    
    [1]: https://en.wikipedia.org/wiki/Inversion_of_control
    rix1 committed May 8, 2024
    Configuration menu
    Copy the full SHA
    9658070 View commit details
    Browse the repository at this point in the history