Tree Reference¶
Bases: Gradient
A Rich tree convenience constructor with gradient rendering.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
RenderableType
|
Root label for the tree. |
required |
style
|
StyleType
|
Base tree style. |
'tree'
|
guide_style
|
StyleType
|
Style for guide lines. |
'tree.line'
|
expanded
|
bool
|
Whether child nodes are expanded. |
True
|
highlight
|
bool
|
Whether Rich should highlight labels. |
False
|
hide_root
|
bool
|
Whether to hide the root label. |
False
|
colors
|
Optional[Sequence[ColorType]]
|
Foreground gradient color stops. |
None
|
bg_colors
|
Optional[Sequence[ColorType]]
|
Background gradient color stops. |
None
|
rainbow
|
bool
|
Whether to generate a rainbow palette. |
False
|
hues
|
int
|
Number of auto-generated hues. |
5
|
repeat_scale
|
float
|
Scale factor controlling gradient repeats. |
2.0
|
expand
|
bool
|
Whether the gradient frame expands. |
True
|
justify
|
AlignMethod
|
Horizontal alignment. |
'left'
|
vertical_justify
|
VerticalAlignMethod
|
Vertical alignment. |
'middle'
|
console
|
Optional[Console]
|
Optional Rich console. |
None
|
highlight_words
|
Optional[HighlightWordsType]
|
Word highlight configuration. |
None
|
highlight_regex
|
Optional[HighlightRegexType]
|
Regex highlight configuration. |
None
|
Source code in src/rich_gradient/tree.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | |
tree
property
¶
Return the underlying Rich tree.
__init__(label, *, style='tree', guide_style='tree.line', expanded=True, highlight=False, hide_root=False, colors=None, bg_colors=None, rainbow=False, hues=5, repeat_scale=2.0, expand=True, justify='left', vertical_justify='middle', console=None, highlight_words=None, highlight_regex=None)
¶
Initialize a gradient-enabled Rich tree.
Source code in src/rich_gradient/tree.py
add(label, *, style=None, guide_style=None, expanded=True, highlight=False)
¶
Forward add to the underlying Rich tree.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
RenderableType
|
Label for the child tree node. |
required |
style
|
StyleType | None
|
Optional style for the child label. |
None
|
guide_style
|
StyleType | None
|
Optional style for the child guide lines. |
None
|
expanded
|
bool
|
Whether the child node is expanded. |
True
|
highlight
|
Optional[bool]
|
Whether Rich should highlight the child label. |
False
|
Returns:
| Type | Description |
|---|---|
Tree
|
The newly-created Rich tree node. |