styled_print
A simple utility for printing styled text to the terminal with color, background, and other styles.
Installation
You can install styled_print via pip:
pip install styled_print
Usage
The styled_print function allows you to print styled text in the terminal. It accepts a string and an options dictionary to customize the output.
Function Signature:
styled_print(string, options)
Parameters:
string(str): The text you want to print.options(dict): A dictionary containing styling options.
The dictionary can include:color(str, optional): The text color.
e.g.,"red","blue","green", etc.styles(list, optional): A list of text styles.
Possible values:["bold"],["underline"],["italic"], etc.bg_color(str, optional): The background color.
e.g.,"on_white","on_red", etc.uppercase(bool, optional): IfTrue, converts the text to uppercase.lowercase(bool, optional): IfTrue, converts the text to lowercase.align(str, optional): Align the text.
Possible values:"left","center","right". Default is"left".padding(int, optional): Number of spaces to add around the text for padding. Default is0.border(bool, optional): IfTrue, prints the text with a border.
Example Usage:
from styled_print import styled_print
# Print bold red text on a white background
styled_print("Hello", {
"color": "red",
"styles": ["bold"],
"bg_color": "on_white"
})
# Print uppercase text with padding and border
styled_print("Hello World", {
"color": "blue",
"styles": ["underline"],
"bg_color": "on_yellow",
"uppercase": True,
"padding": 2,
"border": True
})
# Print center-aligned, green italic text
styled_print("Centered Text", {
"color": "green",
"styles": ["italic"],
"align": "center"
})
Example Output:
For the example:
styled_print("Hello", {
"color": "red",
"styles": ["bold"],
"bg_color": "on_white"
})
You will get output like this:
Hello (in bold red on white background)
For the second example with padding and a border, the output will look like this:
--------------------------------------------------
| HELLO WORLD |
--------------------------------------------------
Customization Options:
- Color: The available text colors are the basic colors supported by
termcolor(red,blue,green, etc.). - Text Styles: You can apply multiple styles to text, such as:
"bold": Makes the text bold."underline": Underlines the text."italic": Italicizes the text (not all terminals support this).
- Background Color: Background color options are also from
termcolor(on_white,on_red, etc.). - Alignment: You can align text to the
"left","center", or"right". - Padding: Adds a padding (space) around the text for visual clarity.
- Border: Wraps the text with a simple ASCII border.
Example Output:
-
Uppercase Example:
styled_print("hello", {"uppercase": True})
Output:
HELLO -
Text with Padding:
styled_print("padded text", {"padding": 4})
Output:
" padded text " -
Text with Border:
styled_print("bordered text", {"border": True})
Output:
--------------------------- | bordered text | ---------------------------
Demo
License
This package is licensed under the MIT License.
Metadata
Release files for styled-print 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| styled_print-0.1.3.tar.gz | 4.1 kB | Without provenance | Details for styled_print-0.1.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| styled_print-0.1.3-py3-none-any.whl | Python 3 | none | any | Details for styled_print-0.1.3-py3-none-any.whl |
Total release size: 8.3 kB
Release files / styled_print-0.1.3.tar.gz
| Download URL | styled_print-0.1.3.tar.gz |
|---|---|
| Size | 4.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6b0324135ed48772ee978c5e56564c8d07666fa0614eda3aae3c0beef4a1ee60
|
|
BLAKE2b-256 checksum How to use checksums |
106109705094613dcb1962e50720e6f997670c42d6adbfc69cf313d0d945b88a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.4
|
Release files / styled_print-0.1.3-py3-none-any.whl
| Download URL | styled_print-0.1.3-py3-none-any.whl |
|---|---|
| Size | 4.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8ce5e186476aae1aea454723dddf810253e8de2ba67456b0329d1d6a9d92d1f9
|
|
BLAKE2b-256 checksum How to use checksums |
056bdc5c6759d0211617c540d5665a35d0246624489b2051612f70e45c810c85
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.4
|
Security for styled-print 0.1.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.