Giter Club home page Giter Club logo

cursor's Introduction

License: GPL v3

PyPI version

Code Health

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

Projects using cursor

halo: beautiful terminal spinners in Python

pipenv: a tool that aims to bring the best of all packaging worlds to the Python world

cursor's People

Contributors

gijstimmers avatar manrajgrover avatar goggle avatar

Watchers

John Vandenberg avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.