On Fri, Feb 17, 2012 at 12:38 PM, brandon w <bbbggg...@gmail.com> wrote: > I made a timer that counts down from five minutes. This code runs fine but I > a seeing a cursor blinking on the first number as the code is running. How > do I avoid this? > > I am using gnome-terminal and Python 2.6.6. > > > #!/usr/bin/python > > import time > import sys > import os > > def countd(): > > seconds = 59 > minutes = 4 > five_minutes = 0 > > os.system('clear') > > while five_minutes != 300: > sys.stdout.write("%d:%02.f\r" % (minutes, seconds)) > sys.stdout.flush() > seconds -= 1 > if seconds == -1: > minutes -= 1 > seconds = 59 > > five_minutes += 1 > time.sleep(1) > > countd() > > > > Brandon >
I believe that the curses[1] library can do this, though that may be somewhat complex (curses is essentially a GUI toolkit for the terminal). You should probably read up on the tutorial mentioned there. HTH, Hugo [1] http://docs.python.org/library/curses.html _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor