On 08/17/2011 04:02 AM, Alan Gauld wrote:
On 17/08/11 04:05, brandon w wrote:
I am trying to print in the same place to make a clock in a tkinter
window. I will loop the following code to update the time.
This is not a tkinter program so its completely irrelevant to your
stated aim. In tkinter  how print works is of no importance. You will
not be using print in a tkinter program you will simply be changing
the text in a widget.

This seems to work but it is not printing in the same place:

#!/usr/bin/python
#Python 2.6.6

import time

for t in range(5):
digits = time.strftime('%H:%M:%S')
print "\r", digits
time.sleep(0.1)

That's because you are using \r which is platform dependant
(and even terminal dependant on *nix) . You don't say which
platform you are using. Using \b (backspace) may be more
successful.

>>> print ("test","\b\b\b\b\b\b","Foo")
 Foo

But, as I say, that won't be very useful in tkinter since you
won't be using print().

I am using Linux with Python 2.6.6.

"\b" seems like a good simple solution to the problem.
I guess I will have to find another way to create a digital clock in a tkinter window.
I found someone who made a Python clock but I want to create my own version
without just coping his. I will learn more if I try to do it myself.
Thanks for your help.
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to