xnano.output
xnano.output
¶
xnano.output
What a canvas has drawn, and the text a canvas on the screen held back.
Classes:
-
Output–The frames a canvas has drawn, and the text printed while it was on the screen.
Output
¶
The frames a canvas has drawn, and the text printed while it was on the screen.
Get it from canvas.output. To print the current frame, use
Canvas.render.
Attributes:
-
is_captured(bool) –Whether a canvas on the screen is holding back what is printed, so it cannot corrupt the screen.
Examples:
import xnano
with xnano.new(width=12, height=2) as canvas:
canvas.write('hello', x=1, y=1)
canvas.output.render()
assert canvas.output.snapshot().lines()[1] == ' hello'
Create the output's view of a canvas. Use canvas.output instead of calling this.
Parameters:
Methods:
-
render–Draw a frame now and return it.
-
snapshot–Return the last frame that was drawn, without drawing.
-
take_captured–Return the text printed or logged since the last call, from a canvas on the screen.
Source code in xnano/output.py
is_captured
property
¶
is_captured: bool
Whether a canvas on the screen is holding back what is printed, so it cannot corrupt the screen.
render
¶
render() -> FrameSnapshot
take_captured
¶
take_captured() -> str
Return the text printed or logged since the last call, from a canvas on the screen.
A canvas on the screen holds back anything written to standard output or standard error so it cannot corrupt the screen. Text you do not take is printed when the canvas closes.