xnano.demo
The feature demo: python -m xnano. It opens with an animation, then fills the window with
live panels that each use a different part of xnano. It is written with the public API only,
so it doubles as a larger example.
Functions:
-
main
–
Run the demo in the whole window.
edge
A column of the window, as a formula of its width.
Source code in xnano/demo.py
| def edge(fraction: float) -> NumericValue[int | float]:
"""A column of the window, as a formula of its width."""
return (ParentWidth * fraction) // 1
|
row
A row below the title, as a formula of the window's height.
Source code in xnano/demo.py
| def row(fraction: float) -> NumericValue[int | float]:
"""A row below the title, as a formula of the window's height."""
return 1 + ((ParentHeight - 2) * fraction) // 1
|
wordmark
The xnano block letters, with see-through gaps so the animation shows between them.
Source code in xnano/demo.py
| def wordmark() -> Buffer:
"""The ``xnano`` block letters, with see-through gaps so the animation shows between them."""
buffer = Buffer(width=max(len(line) for line in WORDMARK), height=len(WORDMARK))
for y, line in enumerate(WORDMARK):
for x in range(buffer.width):
character = line[x] if x < len(line) else ' '
if character == ' ':
buffer[x, y] = Cell(' ', is_transparent=True)
else:
buffer[x, y] = Cell(character, style=Style(INK, bold=True))
return buffer
|
main
Run the demo in the whole window.
Source code in xnano/demo.py
| def main() -> None:
"""Run the demo in the whole window."""
with xnano.open(mouse=True, title='xnano', state=None) as terminal:
_Demo(terminal).start()
terminal.run(quit_on=('q', 'ctrl+c'))
|