functui.common¶
Usefull nodes.
- class functui.common.BorderStyle(line_v: str, line_h: str, corner_tl: str, corner_tr: str, corner_br: str, corner_bl: str)[source]¶
Data structure that represents a border, may be used in
border_custom.
- functui.common.bg(color: Color) WrapperNode[source]¶
Style all descendants with specified background.
Styling may be ovverriden with another styling node.
See also
If you want to style only certain wrapper nodes concider using
styled
- functui.common.bg_char(char: str) WrapperNode[source]¶
Fill background with char
- functui.common.bg_fill(child: Layout)¶
Fill background with whitespace.
Usefull if you want to fill background with a color using
bgorstyled
- functui.common.blink(node: Layout)[source]¶
Style all descendants as blink.
Use this sparingly.
See also
If you want to style only certain wrapper nodes concider using
styled
- functui.common.bold(node: Layout)[source]¶
Style all descendants as bold.
See also
If you want to style only certain wrapper nodes concider using
styled
- functui.common.border_ascii(child: Layout)¶
Puts a border consisting of ascii characters around a layout.
- functui.common.border_with_title(title: Layout, border_node=<function custom_border.<locals>._custom_border>)[source]¶
Border with a title attached on top.
- Parameters:
title – Layout to render on top.
border_node – WrapperNode to put around child layout.
- functui.common.combine(*wrapper_nodes: WrapperNode) WrapperNode[source]¶
Combines multiple wrapper nodes into one.
Examples
>>> from functui.common import * >>> border_and_center = combine(border, center) >>> text("hi") | border | center == text("hi") | border_and_center True
- functui.common.custom_border(style: BorderStyle) WrapperNode[source]¶
Puts a border around a layout in a custom style.
- functui.common.custom_padding(top: int = 0, bottom: int = 0, left: int = 0, right: int = 0) WrapperNode[source]¶
Add padding / Shrink a layout by differences
- functui.common.dim(node: Layout)[source]¶
Style all descendants as dim.
See also
If you want to style only certain wrapper nodes concider using
styled
- functui.common.empty(node: Layout)[source]¶
A dummy wrapper node for situation when a wrapper node is required but not needed.
This wrapper node may be usefull if you are for example making a button which gets a border around it if it is selected.
Examples
>>> from functui.common import * >>> selected = True >>> layout = text("button") | (border if selected else empty)
- functui.common.fg(color: Color) WrapperNode[source]¶
Style all descendants with specified foreground.
Styling may be ovverriden with another styling node.
See also
If you want to style only certain wrapper nodes concider using
styled
- functui.common.hbar = (<function hbar_custom>, <function min_size_constant.<locals>.<lambda>>, functools.partial(<functools._lru_cache_wrapper object>, '─'))¶
Horizontal bar.
- functui.common.hbar_ascii = (<function hbar_custom>, <function min_size_constant.<locals>.<lambda>>, functools.partial(<functools._lru_cache_wrapper object>, '─'))¶
An ascii horizontal bar.
- functui.common.hbar_double = (<function hbar_custom>, <function min_size_constant.<locals>.<lambda>>, functools.partial(<functools._lru_cache_wrapper object>, '═'))¶
A double horizontal bar.
- functui.common.hbar_thick = (<function hbar_custom>, <function min_size_constant.<locals>.<lambda>>, functools.partial(<functools._lru_cache_wrapper object>, '━'))¶
A thick horizontal bar.
- functui.common.hbox(children: Iterable[Layout], at_x: int = 0)[source]¶
A container node that arranges its chilren Horizontaly.
Children will be shrunk to their minimum size along the x axis.
- Parameters:
children
at_x – X coordinate to start rendering children at. Usefull for implementing scrolling.
- functui.common.italic(node: Layout)[source]¶
Style all descendants as italic.
See also
If you want to style only certain wrapper nodes concider using
styled
- functui.common.nothing()[source]¶
A dummy node for situations where a node is required but not needed.
- functui.common.offset(x: int = 0, y: int = 0) WrapperNode[source]¶
Offset layout by a difference
Positive values move down and right. Negative values of move up and left.
- functui.common.padding(child: Layout)¶
Add padding to left and right of a child layout.
Eqivelent to
custom_padding```(left=1, right=1)`.
- functui.common.push_rule(rule: StyleRule) WrapperNode[source]¶
Use style rule for this wrapper node’s descendants unless overriden.
- functui.common.reverse(node: Layout)[source]¶
Style all descendants as reverse.
See also
If you want to style only certain wrapper nodes concider using
styled
- functui.common.static_box(children: Iterable[Layout]) Layout[source]¶
A container node that does not arrange its children in any way
Usefull if you want to draw nodes on top of each other.
- Parameters:
children – Children will be rendered in order. (First child rendered first)
Examples
>>> from functui import Rect, layout_to_str >>> from functui.common import * >>> layout = static_box([ ... text("first") | border | shrink, ... text("second") | border | shrink | offset(1, 2) ... ]) | border >>> print(layout_to_str(layout, Rect(10, 8))) ┌────────┐ │┌─────┐ │ ││first│ │ │└┌──────│ │ │second│ │ └──────│ │ │ └────────┘
- functui.common.strike_through(node: Layout)[source]¶
Style all descendants as strike_through.
See also
If you want to style only certain wrapper nodes concider using
styled
- functui.common.styled(node: WrapperNode, rule: StyleRule) WrapperNode[source]¶
Style a wrapper node with specified rule
As with all other styling nodes, styles assigned with previous nodes will be kept unless overridden.
Tip
If you want to style multiple wrapper nodes with same style concider using
combine.- Parameters:
node – Wrapper node to be styled.
style – Style to assign to the wrapper node
- functui.common.text(string: str)[source]¶
A simple text node.
- Parameters:
string – A string that may include new line characters.
Examples
>>> from functui import layout_to_str, Rect >>> from functui.common import text >>> layout = text("foo\nbar\nbaz") >>> print(layout_to_str(layout, Rect(3, 3))) foo bar baz
- functui.common.underline(node: Layout)[source]¶
Style all descendants as underlined.
See also
If you want to style only certain wrapper nodes concider using
styled
- functui.common.vbar = (<function vbar_custom>, <function min_size_constant.<locals>.<lambda>>, functools.partial(<functools._lru_cache_wrapper object>, '│'))¶
Vertical bar.
- functui.common.vbar_ascii = (<function vbar_custom>, <function min_size_constant.<locals>.<lambda>>, functools.partial(<functools._lru_cache_wrapper object>, '|'))¶
An ascii vertical bar.
- functui.common.vbar_double = (<function vbar_custom>, <function min_size_constant.<locals>.<lambda>>, functools.partial(<functools._lru_cache_wrapper object>, '║'))¶
A double vertical bar.
- functui.common.vbar_thick = (<function vbar_custom>, <function min_size_constant.<locals>.<lambda>>, functools.partial(<functools._lru_cache_wrapper object>, '┃'))¶
A thick vertical bar.
- functui.common.vbox(children: Iterable[Layout], at_y: int = 0, reverse: bool = False)[source]¶
A container node that arranges its chilren verticaly.
Children will be shrunk to their minimum size along the y axis.
- Parameters:
children
at_y – Y coordinate to start rendering children at. Usefull for implementing scrolling.