AndyL
AndyL

Reputation: 14673

Display constantly updating information in-place in command-line window using python?

I am essentially building a timer. I have a python script that monitors for an event and then prints out the seconds that have elapsed since that event.

Instead of an ugly stream of numbers printed to the command line, I would like to display only the current elapsed time "in-place"-- so that only one number is visible at any given time.

Is there a simple way to do this?

If possible I'd like to use built-in python modules. I'm on Windows, so simpler the better. (E.g. no X11).

Upvotes: 1

Views: 1047

Answers (2)

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 798556

Outputting \b will move the output cursor left 1 cell, and outputting \r will return it to column 0. Make sure to flush the output often though.

Upvotes: 3

Ishpeck
Ishpeck

Reputation: 2041

I use this: http://newcenturycomputers.net/projects/wconio.html

Upvotes: 3

Related Questions