A class for drawing table in text console for python in windows or linux
Project description
TextTable
TextTable is a lightweight Python module that helps developers draw well-formatted tables in the console using ASCII or Unicode box-drawing characters.
It is designed for command-line applications where clear tabular output and optional pagination are required.
Features
- Draw tables using ASCII or Unicode borders
- Support for single-line, double-line, and dashed table styles
- Automatic column width calculation
- Left, right, and center text alignment
- Pagination support for large datasets
- Cross-platform (Windows, Linux, macOS)
Installation
pip install texttable
Basic Usage
from Texttable import TextTable
t = TextTable(ttype='=', page_size=10)
t.set_columns(['Column 1', 'Column 2', 'Column 3'])
t.add_row(['Data 1', 'Data 2', 'Data 3'])
t.add_row(['More', 'Sample', 'Values'])
print(t)
Pagination Example
from Texttable import TextTable
t = TextTable(ttype='-', page_size=5)
t.set_columns(['ID', 'Name', 'Value'])
for i in range(20):
t.add_row([str(i), f'Item {i}', str(i * 10)])
t.print_with_pagination()
##Use keyboard input to navigate:
1 → Next page
2 → Previous page
0 / Enter → Exit
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 pytexttable-0.1.0.tar.gz.
File metadata
- Download URL: pytexttable-0.1.0.tar.gz
- Upload date:
- Size: 4.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a9f2614bbef5d32e2d5e6904667ef323fe7f1967eabdc15fa52fd97b13eb04f7
|
|
| MD5 |
b769c17ef03dc7c5e5344dacc9e70fb6
|
|
| BLAKE2b-256 |
92a0287cf6d0bc6ac76b15757b718bb4a9c19f3af5c54ff0d4477d0d98e22737
|
File details
Details for the file pytexttable-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pytexttable-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d09cb5e1b17f9aa18ffd83ab8ab5b8dfe0bb176fe55ed0e3a8d0925c2f934914
|
|
| MD5 |
f1f0b305c0edac38b7cfe9784e6e649b
|
|
| BLAKE2b-256 |
c3f33c0006fdea4d5610e775df2e3a582445ed39a5293f347b493c9657b6b052
|