Skip to main content

A ridiculously lightweight Python library for effortlessly applying ANSI escape color & style codes to Windows CMD.

Project description

quick_styles (wip)

An unbelievably lightweight Python library for effortlessly applying ANSI escape color & style codes to Windows CMD and other ANSI-supported terminals


Description

quick_styles enhances the experience of using the current unintuitive ANSI escape code system for text styling in Python. With quick_styles, you can easily generate ANSI codes with set parameters, save styles for future use, and implement custom codes for personalized styles.

Download

From PyPI using pip:

pip install quick_styles

Usage

Example program

Before we proceed to the explict info regarding the library's functionality, here's a preview of the core functions of quick_styles to get a sense of its capabilities:

import quick_styles as qs

print("Hi there! I'm a boring print statement. By default, I am unable to be styled and my appearance is immutable. "
      "Womp womp!")

print("\033[34mTypically, you would have to manually surround me with ANSI escape codes. Not only is this method of "
      "styling tedious, but also makes the text less readable and does not clearly indicate what styles are being "
      "applied to the person inspecting the code.\033[0m")

qs.xprint("Well, well, what do we have here? I'm a styled print statement as well, but there are no ANSI codes "
          "visible. It's just an additional parameter!", color="blue")
ex_input = qs.xinput("This applies to inputs too!")

qs.xprint("This works for applying a text style as well.", styles="bold")
qs.xprint("Or multiple...", styles=["bold", "underline"])

# To apply a particular assortment of styles to multiple strings, you can create custom ANSI codes to apply in the future
qs.custom_codes["red_title"] = qs.create_code(color="black", bgcolor="red", styles="bold")
qs.xprint("Not only do I possess the previously listed styles", custom_code="red_title")
qs.xprint("but I do as well!", custom_code="red_title")

# There are also modifiers for the content of the string itself, such as
qs.xprint("a warning format,", modifier="warning")
# ! a warning format, !

qs.xprint("or prepending the text with the current time!", modifier="time_display")
# [14:19:21] or prepending the text with the current time!

# Default values can also be modified
qs.defaults.values["color"] = "red"
qs.defaults.values["styles"] = "bold"
qs.defaults.values["modifier"] = "warning"

# Subsequent calls without explicit values resort to default values
qs.xprint("I'm styled, yet the parameters aren't directly stated!")

# Specified values override defaults
qs.xprint("I'm still special!", color="green")

# Reset function returns defaults to initial values
qs.defaults.reset()

# Strings can also be styled without being immediately printed
styled_string = qs.style_string("You can't see me...", styles="italic")

Function Refrence

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

quick_styles-1.0.0.tar.gz (4.5 kB view details)

Uploaded Source

File details

Details for the file quick_styles-1.0.0.tar.gz.

File metadata

  • Download URL: quick_styles-1.0.0.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.4

File hashes

Hashes for quick_styles-1.0.0.tar.gz
Algorithm Hash digest
SHA256 5dcb7b441cd1c5d9e569c705998c5ee0bb2002d2bae62ba246455b003e9c5a78
MD5 46e2401d641d6f8d605a5b13b714c801
BLAKE2b-256 3044a6d71f5e7a66b1d3513632b703e129eec32b3954d44865e7cf699fbb2454

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page