This should just be a drop-in replacement:
from carambar import tqdm
for item in tqdm(items):
...
A CaramBar takes a text
object. This can be either a raw string, or any object that properly implements __format__
:
with CaramBar('Hello world!'):
...
class BottomDisplay:
def __format__(self, fmt: str) -> str:
content = 'Some really important contextual information'
return format(content, fmt)
with CaramBar(BottomDisplay()):
...
Together with this, you can tell the CaramBar to update its display regularly, so you get real-time information:
with CaramBar(text=BottomDisplay(), update_every=1):
...
With only a function:
from carambar.tools import fmtee
def get_info():
...
with CaramBar(fmtee(get_info)):
...
Composing a display:
from carambar import fmt
my_display = (
fmt.Layout(sep=':')
.field(align=fmt.LEFT, pack=fmt.ASIS, src=get_temperature)
.field(align=fmt.MIDDLE, pack=fmt.ASIS, src=get_message)
.field(align=fmt.LEFT, pack=fmt.ASIS, src=get_remaining_info)
)
with CaramBar(my_display):
...