A comprehensive library for colored terminal output, progress bars, tables, and shapes using ANSI escape codes
Project description
ColorTerm ๐จ
A comprehensive Python library for colored terminal output, progress bars, tables, and shapes using ANSI escape codes. Perfect for making your CLI applications more readable, interactive, and user-friendly!
Features
๐จ Text Output
- Basic Colors: 8 standard colors + 8 bright colors
- Text Styles: Bold, italic, underline, and more
- Semantic Printers: Success, error, warning, info with icons (โ, โ, โ , โน)
๐ Progress Bars
- ProgressBar: Static progress bar with customizable appearance
- AnimatedProgressBar: Smooth animated progress with transitions
- SpinnerProgressBar: Progress with spinner animations (dots, line, arrow, circle)
- MultiProgressBar: Display multiple progress bars simultaneously
๐ Tables
- Table: Basic tables with headers, rows, and alignment
- ColoredTable: Tables with row coloring and alternating colors
- Grid: Grid layout for cell-based content
- 5 Border Styles: Light, heavy, double, rounded, ASCII
๐ท Shapes
- Line: Horizontal and vertical lines
- Rectangle: Filled or bordered rectangles
- Circle: Filled or bordered circles
- Triangle: Triangles in 4 orientations (up, down, left, right)
- Diamond: Diamond shapes
- Box: Unicode boxes with titles and multiple styles
Installation
pip install terminal-colorize
Or install from source:
git clone https://github.com/mmssajith/colorterm.git
cd colorterm
pip install -e .
Quick Start
Colored Text
from colorterminal import Printer, StylePrinter, SemanticPrinter
# Basic colors
Printer.red("Error message")
Printer.green("Success message")
Printer.blue("Information")
# Text styles
StylePrinter.bold("Bold text")
StylePrinter.underline("Underlined text")
StylePrinter.bold_red("Bold red text")
# Semantic messages with icons
SemanticPrinter.success("Operation completed") # โ
SemanticPrinter.error("Connection failed") # โ
SemanticPrinter.warning("Low disk space") # โ
SemanticPrinter.info("Processing data") # โน
Progress Bars
from colorterminal import AnimatedProgressBar, MultiProgressBar, Colors
# Single animated progress bar
bar = AnimatedProgressBar(total=100, color_code=Colors.GREEN)
bar.simulate(duration=2, steps=50)
# Multiple progress bars
multi = MultiProgressBar()
multi.add_bar("Download", total=100, color_code=Colors.GREEN)
multi.add_bar("Upload", total=100, color_code=Colors.BLUE)
multi.update("Download", 75)
multi.update("Upload", 45)
multi.display_all()
Tables
from colorterminal import Table, ColoredTable, Colors
# Basic table
table = Table(headers=["Name", "Age", "City"])
table.add_row(["Alice", "30", "New York"])
table.add_row(["Bob", "25", "San Francisco"])
table.display()
# Colored table with row colors
table = ColoredTable(headers=["Test", "Result", "Time"])
table.add_row(["Test 1", "PASSED", "0.5s"], color=Colors.GREEN)
table.add_row(["Test 2", "FAILED", "1.2s"], color=Colors.RED)
table.display()
Shapes
from colorterminal import Line, Rectangle, Circle, Box, Colors
# Draw a line
Line(length=40, color_code=Colors.CYAN).draw()
# Draw a rectangle
Rectangle(width=20, height=5, color_code=Colors.GREEN).draw()
# Draw a circle
Circle(radius=5, filled=True, color_code=Colors.MAGENTA).draw()
# Draw a box with title
Box(width=40, height=3, title="Status", style="double").draw()
Complete Examples
Dashboard Example
from colorterminal import (
Box, ColoredTable, MultiProgressBar,
SemanticPrinter, StylePrinter, Colors
)
# Header
Box(width=60, height=1, style="double", title="System Dashboard").draw()
# System status
StylePrinter.bold("System Status:")
SemanticPrinter.success("CPU: Normal (45%)")
SemanticPrinter.warning("Memory: High (85%)")
SemanticPrinter.error("Disk: Critical (92%)")
# Services table
table = ColoredTable(headers=["Service", "Status", "Uptime"])
table.add_row(["Web Server", "Running", "99.9%"], color=Colors.GREEN)
table.add_row(["Database", "Running", "100%"], color=Colors.GREEN)
table.add_row(["Cache", "Degraded", "98.5%"], color=Colors.YELLOW)
table.display()
# Resource usage
multi = MultiProgressBar()
multi.add_bar("CPU", total=100, color_code=Colors.GREEN)
multi.add_bar("Memory", total=100, color_code=Colors.YELLOW)
multi.add_bar("Disk", total=100, color_code=Colors.RED)
multi.update("CPU", 45)
multi.update("Memory", 85)
multi.update("Disk", 92)
multi.display_all()
API Reference
Printers
Printer - Basic colored text output
Printer.red(),Printer.green(),Printer.blue(), etc.Printer.bright_red(),Printer.bright_green(), etc.
StylePrinter - Styled and combined text
StylePrinter.bold(),StylePrinter.underline(),StylePrinter.italic()StylePrinter.bold_red(),StylePrinter.bold_green(), etc.
SemanticPrinter - Contextual messages with icons
SemanticPrinter.success()- Green with โSemanticPrinter.error()- Red with โSemanticPrinter.warning()- Yellow with โSemanticPrinter.info()- Cyan with โน
Progress Bars
ProgressBar - Basic progress bar
bar = ProgressBar(total=100, width=40, color_code=Colors.GREEN)
bar.update(50)
AnimatedProgressBar - Animated progress
bar = AnimatedProgressBar(total=100)
bar.animate_to(75, steps=20, delay=0.05)
bar.simulate(duration=2, steps=50)
SpinnerProgressBar - Progress with spinner
bar = SpinnerProgressBar(total=100, spinner_style="dots")
bar.update(50)
MultiProgressBar - Multiple bars
multi = MultiProgressBar()
multi.add_bar("Task 1", total=100, color_code=Colors.GREEN)
multi.update("Task 1", 50)
multi.display_all()
Tables
Table - Basic table
table = Table(
headers=["Col1", "Col2"],
style="light", # light, heavy, double, rounded, ascii
alignment=["left", "center"]
)
table.add_row(["Data 1", "Data 2"])
table.display()
ColoredTable - Table with colors
table = ColoredTable(
headers=["Name", "Status"],
alternating_colors=[None, Colors.BRIGHT_BLACK]
)
table.add_row(["Item 1", "Active"], color=Colors.GREEN)
table.display()
Grid - Grid layout
grid = Grid(columns=3, cell_width=15, cell_height=2)
grid.add_cell("Cell 1")
grid.add_cell(["Multi", "Line"])
grid.display()
Shapes
Line
Line(length=40, orientation="horizontal", color_code=Colors.CYAN).draw()
Rectangle
Rectangle(width=20, height=5, filled=True, color_code=Colors.GREEN).draw()
Circle
Circle(radius=5, filled=False, color_code=Colors.MAGENTA).draw()
Triangle
Triangle(height=5, orientation="up", color_code=Colors.YELLOW).draw()
Diamond
Diamond(size=5, filled=True, color_code=Colors.CYAN).draw()
Box
Box(width=40, height=3, style="double", title="Title").draw()
Examples
Check the examples/ directory for complete examples:
basic_example.py- Text output basicsshapes_example.py- All shape typestables_example.py- Table demonstrationsprogress_example.py- Progress bar examplesdashboard_example.py- Complete dashboard
Run any example:
python examples/basic_example.py
Colors & Styles
Available Colors
Colors.RED, Colors.GREEN, Colors.BLUE, Colors.YELLOW
Colors.MAGENTA, Colors.CYAN, Colors.WHITE, Colors.BLACK
Colors.BRIGHT_RED, Colors.BRIGHT_GREEN, Colors.BRIGHT_BLUE
Colors.BRIGHT_YELLOW, Colors.BRIGHT_MAGENTA, Colors.BRIGHT_CYAN
Available Styles
Styles.BOLD, Styles.ITALIC, Styles.UNDERLINE
Styles.DIM, Styles.BLINK, Styles.REVERSE, Styles.STRIKETHROUGH
Manual Colorization
from colorterminal import colorize, stylize, Colors, Styles
print(colorize("Custom text", Colors.MAGENTA))
print(stylize("Styled text", Styles.BOLD, Styles.UNDERLINE, Colors.CYAN))
Comparison with Similar Libraries
| Feature | ColorTerm | Colorama | Rich | Termcolor |
|---|---|---|---|---|
| Basic Colors | โ 16 colors | โ 8 colors | โ 256 colors | โ 8 colors |
| Text Styles | โ Full support | โ Basic | โ Full support | โ Basic |
| Progress Bars | โ Multiple types | โ | โ Advanced | โ |
| Animated Progress | โ | โ | โ | โ |
| Multi Progress | โ | โ | โ | โ |
| Tables | โ Multiple styles | โ | โ Advanced | โ |
| Shapes/Drawing | โ 6+ shapes | โ | โ Limited | โ |
| Semantic Printers | โ With icons | โ | โ | โ |
| Border Styles | โ 5 styles | โ | โ | โ |
| No Dependencies | โ | โ | โ (Pygments, etc.) | โ |
| Python 3.6+ | โ | โ | โ 3.7+ | โ |
| Windows Support | โ | โ | โ | โ |
When to Use ColorTerm
- โ Need progress bars, tables, and shapes in one package
- โ Want zero external dependencies
- โ Building CLI dashboards and TUIs
- โ Need simple API with rich features
- โ Want animated progress indicators
When to Use Alternatives
- Colorama: Simple cross-platform color support only
- Rich: Need advanced layouts, syntax highlighting, or markdown rendering
- Termcolor: Minimal color-only solution
Compatibility
- โ Linux
- โ macOS
- โ Windows 10+ (with ANSI support)
Requirements
- Python 3.8+
- No external dependencies
License
MIT License - see LICENSE file for details.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Links
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file terminal_colorize-2.0.2.tar.gz.
File metadata
- Download URL: terminal_colorize-2.0.2.tar.gz
- Upload date:
- Size: 49.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3be152f9892d13ed1184e6aba81f4f1e97bc0eb74d0f636445531df19c4bd85f
|
|
| MD5 |
64e5fe3690f4ed4447fbb4189b169a26
|
|
| BLAKE2b-256 |
29359d2bdf74c8a677255df9548a45849f4db2740dc294c7203507092a9aa082
|
File details
Details for the file terminal_colorize-2.0.2-py3-none-any.whl.
File metadata
- Download URL: terminal_colorize-2.0.2-py3-none-any.whl
- Upload date:
- Size: 28.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5c1e8a8ed7941d7163275b97686e7d0a22120689ba6ddd0e18ddc19de96e411a
|
|
| MD5 |
98a302b2692b59333c71adeb3cc40951
|
|
| BLAKE2b-256 |
079bb945afb75c27b9418d442f08dd694982f060640be72a304cf91a343d0346
|