Skip to main content

OS-agnostic colored & custom Python console print() functions.

Project description

riceprint

About

Author: Kevin Sacca ssriceboat@gmail.com

Simple Python package to replace the built-in print() function. This module contains functions for colored print statements and temporary print statements. Also contained in this package is a full-featured example usage of this package’s tprint() function to create a beautiful progressbar in the console.

Works on Linux, macOS, Windows.

License

MIT License

Copyright (c) 2019 ssriceboat

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Installation

Using pip

pip install riceprint

Usage:

After you have installed the package, check that its working by running the module directly. This will show you all the vailable print colors:

cd /path/to/riceprint-package/src/riceprint/
python riceprint.py

Below is an example of how you can use the functions:

from riceprint import tprint, pprint, progressbar
import time

# Simple pprint, tprint demo
print('This is not using riceprint.')
pprint('This is using riceprint. (Same unless you add some spice)')
pprint('This is using riceprint with style.', 'c')
tprint('This message will be erased by the next line.', 'b')
tprint('This message overwrites the previous tprint and will also be overwritten.', 'r')
pprint('This message overwrites the previous tprint and is permanent.', 'g')

# Overwriting previous messages, like status changes.
message = 'This is an example of something you can do with tprint().'
elements = message.split(' ')
some_colors = ['r', 'g', 'b', 'c', 'm', 'y', 'k', 'w', 'dr', 'dk', 'dc']
for i in range(len(elements)):
   msg = ''
   for y in range(i + 1):
      msg += elements[y] + ' '

   color = some_colors[i]

   tprint(msg, color)
   time.sleep(0.25)

# Progress bar example
for x in range(100 + 1):
   progressbar(x, 100, color='dg', char='\u2587', lend='|', rend='|')
   time.sleep(0.01)

# Adding keep=True here will leave the completed progressbar in the console
progressbar(x, 100, color='dg', char='\u2587', lend='|', rend='|', keep=True)

pprint('Done! I hope you use this package!', 'dm')

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

riceprint-1.1.0.tar.gz (6.7 kB view details)

Uploaded Source

File details

Details for the file riceprint-1.1.0.tar.gz.

File metadata

  • Download URL: riceprint-1.1.0.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3

File hashes

Hashes for riceprint-1.1.0.tar.gz
Algorithm Hash digest
SHA256 5db9cf18e1023c8aad741c861ad0f174f3ecd20e00f1d1e3380b61a15883412d
MD5 6457e61e1005be0826339397c231edf8
BLAKE2b-256 25ca4cf69536506df2b657b0af9cb053c60ad1799ca45cab544e79bebf05690a

See more details on using hashes here.

Supported by

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