Beautiful UIs
Colorful outputs¶
You can easily print colorful text using clypi's cprint
(for "Colored Print") function.
colors.py
from clypi import cprint
cprint("Some colorful text", fg="green", bold=True)
cprint("Some more colorful text", fg="red", strikethrough=True)
python colors.py
Some colorful text
Some more colorful text
You can also style individual pieces of text:
python colors.py
This is blue and this is red
And also create a reusable styler:
colors.py
wrong = clypi.Styler(fg="red", strikethrough=True)
print("The old version said", wrong("Pluto was a planet"))
print("The old version said", wrong("the Earth was flat"))
python colors.py
The old version said Pluto was a planet
The old version said the Earth was flat
Boxed outputs¶
python boxed.py
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Some boxed text ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
Stacks¶
stacks.py
names = clypi.boxed(["Daniel", "Pedro", "Paul"], title="Names", width=15)
colors = clypi.boxed(["Blue", "Red", "Green"], title="Colors", width=15)
print(clypi.stack(names, colors))
python stacks.py
┏━ Names ━━━━━┓ ┏━ Colors ━━━━┓
┃ Daniel ┃ ┃ Blue ┃
┃ Pedro ┃ ┃ Red ┃
┃ Paul ┃ ┃ Green ┃
┗━━━━━━━━━━━━━┛ ┗━━━━━━━━━━━━━┛
Separators¶
python separator.py
━━━━━━━━━ Some title ━━━━━━━━━
Spinners¶
Tip
Read the Spinner API docs for more detail into how to use this component.
spinner.py
import asyncio
from clypi import spinner
@spinner("Doing work")
async def do_some_work():
await asyncio.sleep(2)
asyncio.run(do_some_work())
python spinner.py
Doing work
You can also use it as a context manager:
spinner.py
import asyncio
from clypi import Spinner
async def main():
async with Spinner("Doing something", capture=True) as s:
await asyncio.sleep(2)
asyncio.run(main())
python spinner.py
Doing something