PyStyle

raw JSON →
2.9 verified Fri May 01 auth: no python

PyStyle is a Python library for styling terminal text with colors, gradients, patterns, and effects (e.g., bold, underline). It provides an intuitive API for cross-platform terminal ANSI color output, with support for custom color sequences and animations. The current version is 2.9, with sporadic releases.

pip install pystyle
error ModuleNotFoundError: No module named 'pystyle'
cause pystyle is not installed or the installation is incomplete.
fix
Run 'pip install pystyle' in your terminal.
error AttributeError: module 'pystyle' has no attribute 'Colors'
cause Importing pystyle as a module instead of specific submodules.
fix
Use 'from pystyle import Colors' instead of 'import pystyle' and then pystyle.Colors.
error TypeError: Print() missing 1 required positional argument: 'color'
cause Write.Print() requires a color/gradient argument.
fix
Call Write.Print('text', Colors.green) or use Write.Input() for input prompts.
gotcha Calling Write.Print() without passing a color may raise an error or not style output. Always provide a color or gradient.
fix Use Write.Print('text', Colors.blue) or Write.Input('prompt', Colors.red_to_yellow)
gotcha The 'Center.XCenter' and similar methods rely on terminal width, which may be inaccurate in some IDEs or subprocesses, causing misalignment.
fix Set terminal width explicitly or use a fallback: Center.XCenter(text) might not work as expected in non-terminal environments.
deprecated The 'System' module functions like System.Clear() may be removed in future versions; they rely on OS-specific commands.
fix Use os.system('cls' if os.name == 'nt' else 'clear') directly for clearing the console.
gotcha Gradient effects (e.g., Colors.blue_to_cyan) may not display correctly on terminals that do not support true color (16.7 million colors).
fix Check terminal color support or fall back to basic Colors.blue style.

Prints a string with a blue-to-cyan gradient effect.

from pystyle import Colors, Write
Write.Print('Hello, PyStyle!', Colors.blue_to_cyan, interval=0.05)