Skip to content

zebralt/carambar

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CaramBar

tqdm Integration

This should just be a drop-in replacement:

from carambar import tqdm

for item in tqdm(items):
    ...

More display options

Not just the strings, but the objects too

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):
    ...

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages