Skip to content

truongluan303/py-term-ui

Repository files navigation

Python Terminal UI Library

A library for terminal UI components in Python


Progress Bar

The progress bar is initialized with a max_val, and it will be updated every time the update method is called. If you don't provide a parameter for the update method, the default value will be 1.

Sample usage:

pb = ProgressBar(100)
pb.start()
for i in range(100):
    # do something
    pb.update()

Output:

Progress |█████████---------------------| [33.0%] in 6.7s
Progress |██████████████████████████████| [100.0%] in 20.3s ✅

ASCII Image

Print an image on the terminal.

Sample usage:

from pyterm.components import AsciiImage

# Note: The bigger the width is, the more accurate the ascii image.
# But also make sure that the image's width is smaller than the terminal's width.
ascii_img = AsciiImage("cap.jpg", 100)
ascii_img.print()

# alternatively, you can also do:
print(ascii_img)

# you can also use built in `str` method to get a string version of it instead of printing to console:
img_str = str(ascii_img)

Output:

#############$$$$$$$$$$$$$$$$$$$$$$$%+::++x;::::;;;;;;+++x%$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$$$###$######$$$$$$$$$$$$##$$$$$$$#x;::++;x+::;;;;;;++++x??%$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$@@@@@$$
$$$$$$$$$$$$###$$$$$$$$$$$###$$$$$x;;:;;;;+x;:;++x++xx+xxxx+%$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$@@@@$
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$+;:;:::::;;:;+x++??xx?+++++#$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$@@@$$
$$$$$$$$$$$$$$$$$$$$$$$$$###$$$$$$+;::::::....::;;+xxxxx+;;++?$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
#$$$$$$$$$$$$$$$$$$$$$$#######$$$#:.....::.::.:+x+:;+xx++;;++x$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
######$$$$$$$$$$$$$$$$$########$$#.::;;::;;xx+x?%#?:;+++++++xx$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
################$$$$$$$$$#####$$$#;;x+;?%?+;+;++x+;+++++x+???x$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$@@@
$$$$########################$$$$$#;:::+?%%?x+;;::;+++;;++x??%x%$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$@@@@@
$$$$$#########################$$$#::;+++xxx%%??%%??%%%;+x?%xx?#$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
###############################$$x:xxxxxx?%###%%######x;?%%%%#$$$$$$$$$$$$$$###########$$$$$$$$$$$$$
$$$############################$$#++xx;;;;;;+x??%#####x;?+xx:#@@@@$$$$$$$$$$$$#############$$$$$$$$$
$$$$$$$$$$$$#################$$$$$#xx+;;;;;+xx??%%##%%++;+x:.#@@@@@@@@@@$$$$$$$$$$$#######$$$$$$$$$$
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$?+xxx+xx?%%%?%%%?????;+?x#@@@@@@@@@@@$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$#+xxxxxx??%%??????%?%%%$@@@@@@@@@@@@@@@@@$$$$$$$$$$$$$$$$$$$$$$$$
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$%;;::;;;;+?x?????%%%%%?%$@$$$$@@@@@@@@$$$$$$$$$$$$$$$$$$$$$$$$$$
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$@?:...:::;x?%%%%%%%%%#; ;%$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$@@@$+.....:;x?%%%###%%##;  .x@@@$$$$$@$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$@$%x+:....  ..:;;;++xxxxxx: ..:?#$$@@@$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$@$%x:....  ..     .          .. .:.:+x?%#$$$@@@$$$$$$$$$$$$$$$$$$$$$$$$
$$$$$$$$$$$$$$$$$$$$$$$$$$$$#x;.......        ..:  .     ....:;:.::;;++x%%###$$$$$$$$$$$$$@$$$$$$$$$
$$$$$$$$$$$$$$$$$$$$$$$$$%?x:.:::::::.. ...... ...  ........:;;;;:::;;;;;;;;;;+x?#$$@$$$$$$$$$$$$$$$
$$$$$$$$$$$$$$$$$$$$$$#x;:..::::::::::.....:::...:.  ........:;;;;;:..:;;++++;;::;;+%$@$$$$$$$$$$$$$
$$$$$$$$$$$$$$$$$$##?;::::::::;;::::::...::::::::.......:::;:..:::::::. .:;;;;+;::;:;+%$$$$$$$$$$$$$
$$$$$$$$$$$$$$#%?+;::.....:.::;:::::;:..............::::::;;;:::::...:..  .;++++:::;;;;?$$$$$$$$$$$$
$$$$$$$$$$$%x+;::.::::::::::.:;;;;;;+:......::::::::.;;;;:++;;:::;::::::::..:;;;;:::;;;;?$$$$$$$$$$$
$$$$$$$$$%+:::::::::::::::::.::;;;;:::::::::::::;;:::;;;:;::;;:::;;::::;;+;:.:;;;;::;;;;+%$$$$$$$$$$
$$$$$$$$+...::::.::::::...::.::;:;::;:;;;;;:::::::::;;;;:??:.:::::;;;;;+++;;;::;;;;:::;:;?$$$$$$$$$$
$$$$$$#;....::::..:::::::.::.:::;;:;::::::;;;;;;::::::::;???+.:::::::;++;;;;;+;:;;;..::::+#$$$$$$$$$
$$$$$$+.....:::;:.....:::..:..:::;;:.::;:::::;++:..;+x++???%%?xxx?x;.:;;;;;;;+++:;+:..:::+#$$$$$$$$$
$$$$$?......:::;:..........  ..::::..::::::;;;;;;;;:;x%###%#####%+:.:;:;;;;;++++;:;..::::+#$$$$$$$$$
$$$$#:......::;;;.. .... ..   .:::..:::::::::;;;;;;+;::+%%##%##%;..:::;;;;;;;;+++:; .::::x$$$$$$$$$$
$$$$?.......::;;;:.. .:.  .  ........::::::::;;;;;+;;:.:?##%x?%%?:..:;;;;;;;+++++::..::::?$$$$$$$$$$
$$$$x.......:::;;:... .:...  .:::......::::::;;;;;;;;..+%%x;:;;+??:..:::;;;;++;++.:....::x$$$$$$$$$$
$$$$+......:::::.....  .::.  ..:. .........::::;;;;;:..xx;......:++..:::;;;;;+++;......:;;%$$$$$$$$$
$$$$+......:::......:.. ..   ...  ..........:::;;;;:...:..::::::........:;;;;;++.  ..::;;;;#$$$$$$$$
$$$#:..........::::::::....   .    ..........::::::...:::;;;;:;;::::...:::;;;;;;  ...::;;;:+$$$$$$$$
$$$%;::......:;;;;;;;;;::..     ..    .........::::::::::::::::::::;:::::::;;;;.    ..::;;;;#$$$$$$$
$$$$+:......:::::;;;;;+;;:       ....   ..........::::::::::::;;:::::::::::;:;:     ...::;+;?$$$$$$$
$$$$?.........::;;;;;;;;;:          ....  .......::::::::;;::;:;;;;:::::::::;:      ....:;;;;#$$$$$$
$$$$$;.......::;;;+++++;:.            ...... ....::::::::::::::::;;::::::::::       ..::::::x$$$$$$$
$$$$$?.....::::;;;+++++;:.               ..... ...::::::;;::::;::x++;;;;:::;:         .::..:;?$$$$$$
$$$$$x....::::::;+++++;;:.                   ..  :+++xxxx;:::::::x?????;:::+.         .......;%$$$$$
$$$$$;.::...::::;+++++;;:  .:::::::::::..........:+xxxxxx;.::::..x????+;;;;+:           ....::;#$$$$
$$$$x.....:::::;;+++++;;:   ...  .:::;;::;........++++;;+;.....:;x+xxx:;;;+x?.          ...::;+?$$$$
$$$$;......:::::;;;;;;;:x+      .:;;+;;;:;:......;+;+xxxxx+:.:;x???xxx;:;:+?$?          .::;;+++%$$$
$$$$;:::...:::::::::;;;+$#.    .:;;++;;;:::....:++xx++x????:.:+x??xx??x++;+?#@x         .::;;;+++#$$
$$$%:...   ..::;;;;::..+$$?.   .::;;;;:;++;:..:;xx???x++x??+::xxxx????x+;+??#$$;    .   :.:;;++++x$$
$$$+.   .........:;;;:.:$$$?.    .:;:::.:;+;..;:xx????xxxx?x::xx??%%%??+;x?x%$$#:       :.:::;;+++%$

Releases

No releases published

Packages

No packages published

Languages