A smallish Tkinter question
Martin Franklin
mfranklin1 at gatwick.westerngeco.slb.com
Thu Apr 21 11:32:07 EDT 2005
mediocre_person at hotmail.com wrote:
> """
> What I want: A little window to open with a 0 in it. Every second, the
> 0 should increment by 1.
> What I get: A one second delay, see the window with a 1 in it, and then
> nothing appears to happen. Never see the 0, never see a 2. Any quick
> clues? Thanks. Nick. (Python 2.4, Win98).
> """
>
> from Tkinter import *
> from time import sleep
>
> class Clock:
> def __init__(self, parent):
> self.time = 0
> self.display = Label(parent)
> self.display["font"] = "Arial 16"
> self.display["text"] = str(self.time)
> self.display.pack()
>
> def run(self): #also tried self,parent
> sleep(1.0)
> self.time = self.time + 1
> self.display["text"] = str(self.time)
>
> win = Tk()
> app = Clock(win)
> app.run() #also tried run(win) with self,parent above
> win.mainloop()
>
Nick,
Look at the after method of the Tk widget also google for Tkinter clock
examples should get results
Cheers,
Martin.
More information about the Python-list
mailing list