`curses-colors` is a Python module that provides a simple interface for managing color pairs in a terminal using the `curses` library.
Project description
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,
Project details
Release history Release notifications | RSS feed
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 curses_colors-0.1.0.tar.gz.
File metadata
- Download URL: curses_colors-0.1.0.tar.gz
- Upload date:
- Size: 3.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6cdbca77d1c566a55bcfe88892c3dc32fba44283a47b385e64d303362ff5775d
|
|
| MD5 |
5d40fa3a19346df0be0808fa56c1c554
|
|
| BLAKE2b-256 |
5c7567c294b2f3b913e44666bd77c8614039bbb6b1dd1f8b0cae15a123b27b93
|
File details
Details for the file curses_colors-0.1.0-py3-none-any.whl.
File metadata
- Download URL: curses_colors-0.1.0-py3-none-any.whl
- Upload date:
- Size: 3.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c1195328b43db93c20b0d8ce4b6a36587fe8a6c0d29bb6c8ebc69c87fe186f1c
|
|
| MD5 |
4afa8ceed8be2a671181cfd190277583
|
|
| BLAKE2b-256 |
c8672a43da1c4cc55b373ce65d18284e8d86695d4b9039e4833e480ac7e9c7a3
|