Skip to main content

License: GPL v3

PyPI version

cursor

A small Python package to hide or show the terminal cursor. Works on Linux and Windows, on both Python 2 and Python 3.

demonstration

Disclaimer

The code is almost entirely a copy of James Spencer's answer on StackOverflow.

Installation

The preferred way of installing cursor is via pip. You can install pip with your package manager:

On Ubuntu:

sudo apt-get install python-pip
pip install --user cursor

On Arch:

git clone https://aur.archlinux.org/python-cursor.git
cd python-cursor
makepkg -si

Usage

import cursor
cursor.hide() ## Hides the cursor
cursor.show() ## Shows the cursor

Note that the cursor will stay hidden until you call cursor.show() — even after exiting your python script!

Because of that, pip will install two scripts, which can be run from the command line: cursor_hide and cursor_show.

An alternative is using the HiddenCursor() class in conjunction with Python's with statement. This will make sure that the cursor is shown again after running your code, even if exceptions are raised:

import cursor
with cursor.HiddenCursor():     ## Cursor will stay hidden
    import time                 ## while code is being executed;
    for a in range(1,100):      ## afterwards it will show up again
        print(a)
        time.sleep(0.05)
    

You could also use Python's atexit module:

import cursor
import atexit
import time

atexit.register(cursor.show)    ## Make sure cursor.show() is called
                                ## when exiting

cursor.hide()                   ## Hides cursor
for a in range(1,100):
    print(a)
    time.sleep(0.05)
exit()                          ## Cursor will show again

Contributors

Manraj Singh: allowed setting a customisable stream

Alexander Seiler: packaging for Arch

Patrik Kopkan: packaging for Fedora

psfazila02-hub: keeping setup.py working

Metadata

Release files for cursor 1.3.6

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

Source distribution (sdist)

Source distribution for cursor 1.3.6
File Size Uploaded Provenance Actions
cursor-1.3.6.tar.gz 15.6 kB Without provenance Details for cursor-1.3.6.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for cursor 1.3.6
File Interpreter ABI Platform Actions
cursor-1.3.6-py3-none-any.whl Python 3 none any Details for cursor-1.3.6-py3-none-any.whl

Total release size: 31.5 kB

Release files / cursor-1.3.6.tar.gz

Download URL cursor-1.3.6.tar.gz
Size 15.6 kB
Tags Source
SHA-256 checksum
How to use checksums
ff3586de5a8e9367b689b31092d3f681b03efc92fdcf10aea538778e80f9b67a
BLAKE2b-256 checksum
How to use checksums
a8fe63dc53e5cf7e2c20b6d5b43a92038846e2e301479435203c1d4d857e527c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / cursor-1.3.6-py3-none-any.whl

Download URL cursor-1.3.6-py3-none-any.whl
Size 15.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
aa215f4336ee708f29fd523b55d011f46bed654cc99d9b38e9a513973ef64f65
BLAKE2b-256 checksum
How to use checksums
4be9a343a3bda20ee38708b037e4c2d92c84230001eb8d0b7a98bd73ae12e47b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Security for cursor 1.3.6

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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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