curses-colors
curses-colors is a Python module that provides a simple interface for managing color pairs in a terminal using the curses library. This module allows you to easily initialize and access various color combinations for terminal applications.
Installation
To use the curses-colors module, ensure you have Python installed on your system. The curses library is included with Python on Unix-like systems. For Windows, you may need to install a compatible version of the curses library, such as windows-curses.
Usage
Importing the Module
To use the curses-colors module, you need to import it into your Python script:
import curses
from curses_colors import Colors
Initializing Colors
Before using any color pairs, you must initialize them. This is done by calling the init_colors method of the Colors class. Make sure to do this after initializing the curses screen.
def main(stdscr):
# Initialize colors
Colors.init_colors()
# Example usage of color pairs
stdscr.addstr(0, 0, "Hello, World!", Colors.RED_BLACK)
stdscr.refresh()
stdscr.getch()
curses.wrapper(main)
Accessing Color Pairs
The color pairs are defined as class attributes in the Colors class. You can access them using the format Colors.<BACKGROUND>_<FOREGROUND>. Here are the available color pairs:
Colors.BLACK_BLACKColors.BLACK_REDColors.BLACK_GREENColors.BLACK_YELLOWColors.BLACK_BLUEColors.BLACK_MAGENTAColors.BLACK_CYANColors.BLACK_WHITEColors.RED_BLACKColors.RED_REDColors.RED_GREENColors.RED_YELLOWColors.RED_BLUEColors.RED_MAGENTAColors.RED_CYANColors.RED_WHITEColors.GREEN_BLACKColors.GREEN_REDColors.GREEN_GREENColors.GREEN_YELLOWColors.GREEN_BLUEColors.GREEN_MAGENTAColors.GREEN_CYANColors.GREEN_WHITEColors.YELLOW_BLACKColors.YELLOW_REDColors.YELLOW_GREENColors.YELLOW_YELLOWColors.YELLOW_BLUEColors.YELLOW_MAGENTAColors.YELLOW_CYANColors.YELLOW_WHITEColors.BLUE_BLACKColors.BLUE_REDColors.BLUE_GREENColors.BLUE_YELLOWColors.BLUE_BLUEColors.BLUE_MAGENTAColors.BLUE_CYANColors.BLUE_WHITEColors.MAGENTA_BLACKColors.MAGENTA_REDColors.MAGENTA_GREENColors.MAGENTA_YELLOWColors.MAGENTA_BLUEColors.MAGENTA_MAGENTAColors.MAGENTA_CYANColors.MAGENTA_WHITEColors.CYAN_BLACKColors.CYAN_REDColors.CYAN_GREENColors.CYAN_YELLOWColors.CYAN_BLUEColors.CYAN_MAGENTAColors.CYAN_CYANColors.CYAN_WHITEColors.WHITE_BLACKColors.WHITE_REDColors.WHITE_GREENColors.WHITE_YELLOWColors.WHITE_BLUEColors.WHITE_MAGENTAColors.WHITE_CYANColors.WHITE_WHITE
Example
Here is a complete example of how to use the curses-colors module:
import curses
from curses_colors import Colors
def main(stdscr):
# Initialize colors
Colors.init_colors()
# Clear the screen
stdscr.clear()
# Display text with different color pairs
stdscr.addstr(0, 0, "This is black text on a white background", Colors.WHITE_BLACK)
stdscr.addstr(1, 0, "This is red text on a black background", Colors.RED_BLACK)
stdscr.addstr(2, 0, "This is green text on a yellow background", Colors.GREEN_YELLOW)
# Refresh the screen to show changes
stdscr.refresh()
# Wait for user input
stdscr.getch()
curses.wrapper(main)
License
This module is released under the MIT License. See the LICENSE file for more details.
Contributing
If you would like to contribute to this project, feel free to submit a pull request or open an issue for any bugs or feature requests.
Acknowledgments
This module utilizes the curses library,
Metadata
Release files for curses-colors 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| curses_colors-0.1.0.tar.gz | 3.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| curses_colors-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 7.4 kB
Release files / curses_colors-0.1.0.tar.gz
| Download URL | curses_colors-0.1.0.tar.gz |
|---|---|
| Size | 3.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6cdbca77d1c566a55bcfe88892c3dc32fba44283a47b385e64d303362ff5775d
|
|
BLAKE2b-256 checksum How to use checksums |
5c7567c294b2f3b913e44666bd77c8614039bbb6b1dd1f8b0cae15a123b27b93
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Release files / curses_colors-0.1.0-py3-none-any.whl
| Download URL | curses_colors-0.1.0-py3-none-any.whl |
|---|---|
| Size | 3.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c1195328b43db93c20b0d8ce4b6a36587fe8a6c0d29bb6c8ebc69c87fe186f1c
|
|
BLAKE2b-256 checksum How to use checksums |
c8672a43da1c4cc55b373ce65d18284e8d86695d4b9039e4833e480ac7e9c7a3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|