[Tutor] Printing in the same place
thisisonlyatest at gmx.com
Thu Aug 18 00:20:27 CEST 2011
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:
>> #Python 2.6.6
>> import time
>> for t in range(5):
>> digits = time.strftime('%H:%M:%S')
>> print "\r", digits
> 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
> >>> print ("test","\b\b\b\b\b\b","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
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.
More information about the Tutor