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

Conversation

rix1
Copy link
Member

@rix1 rix1 commented May 8, 2024

This let us do inversion of control1, passing in a callback function that gives more flexibility into how the node is rendered when using show() and save2file().

Example:

def render_node(node):
  if node.level > 2:
    return node.my_property
  return node.some_other_property

tree.show(render_node=render_node)

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
@fredrikgyll fredrikgyll merged commit 3fa8486 into master May 8, 2024
@rix1
Copy link
Member Author

rix1 commented May 8, 2024

I've already opened a PR upstream, caesar0301#227 - will merge this to master in our fork so that we can start using it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants