cjm2671
cjm2671

Reputation: 19456

How do I show a statement repeatedly on the command line using curses?

I'm struggling a little with curses module in Python. I'm trying to get it to show this constantly updating statement (in a loop):

print(i/(time.time()-start_time))

on one line rather than multiple lines. What's the easiest way?

Upvotes: 0

Views: 62

Answers (1)

JadedTuna
JadedTuna

Reputation: 1823

Probably you can use something like this. You just have to adjust it for your needs.

import curses
import time

scr = curses.initscr()
while True:
    try:
        scr.addstr(0, 0, str(time.time()))
        scr.refresh()
    except KeyboardInterrupt: break
curses.endwin()

Upvotes: 2

Related Questions