SVG & HTML exports
You may have noticed the screenshots used throughout this documentation. Fun fact: They are all generated using the module! Some code is run, and its result is then displayed in an SVG image.
To use the recording & export API, simply enter a
Terminal.record context, run some code & save the recording output:
from pytermgui import ColorPicker, pretty, terminal, tim tim.alias("code", "@black #auto dim") with terminal.record() as recording: tim.print("[italic]Everything[/] you print will be captured!") tim.print() tim.print( "By default, only [code]PTG[/]'s prints functions are affected," + "\nbut by overwriting [code]sys.stdout.write[/] you can capture any Python output." )
You can even hide the "window"'s title bar, and get a rectangular image with just your code's output by specifying
chrome=False while exporting:
You can also export as plain HTML! We can't easily show it here (without manually pasting it in) since Termage and its plugin only wrap the SVG API.
For more information, check out the Termage module!