Skip to main content

riceprint

shield1 shield2 shield3 shield4 shield5

About

Author: Kevin Sacca ssriceboat@gmail.com

A simple threaded Python keypress event detector for stopping loops or other threads. Effective for safely stopping large for-loops, continuous functions, and enabling keypress directives for GUIs.

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 ricekey

Usage:

After you have installed the package, check that its working by running the module directly. This will demonstrate an example keypress kill event.

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

Below is an example of how you can use ricekey to stop your main thread if you need to:

from ricekey import kbcontrol
from riceprint import ConsolePrinter, pprint, tprint, progressbar
cp = ConsolePrinter()
import threading
import time

# Start the keypress monitoring thread
thread = threading.Thread(target=kbcontrol, args=())
thread.start()

# While the thread is alive, do something.
i = 0
while thread.isAlive():
   c = cp.palette.colors[i % 16]
   progressbar(i%100, 100, color=c, char='\u2587', lend='|', rend='|')
   time.sleep(0.01)
   i+=1

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

Metadata

Release files for ricekey 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ricekey 1.0.1
File Size Uploaded Provenance
ricekey-1.0.1.tar.gz 4.3 kB Without provenance Details

Release files / ricekey-1.0.1.tar.gz

Download URL ricekey-1.0.1.tar.gz
Size 4.3 kB
Tags Source
SHA-256 checksum
How to use checksums
a20bece53d5c3c47e5bd4c018f945c3749243c18a349675f9ae0619c09aec6c9
BLAKE2b-256 checksum
How to use checksums
2a674e6df7a0af46bae45da485c0f3240e72229a94d43bcfb004e9ceaf2d07dc
Upload date
Uploaded using Trusted Publishing?
What is 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

Security for ricekey 1.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

1.0.1 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page