A smallish Tkinter question
Miki Tebeka
miki.tebeka at zoran.com
Mon Apr 25 07:37:05 EDT 2005
Hello Nick,
> """
> 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).
> """
Read: http://www.pythonware.com/library/tkinter/introduction/ and mainly
http://www.pythonware.com/library/tkinter/introduction/x9507-alarm-handlers-and-other.htm
from Tkinter import *
class Clock(Frame): #<<<
def __init__(self, parent):
Frame.__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): #<<<
self.loop()
def loop(self): #<<<
self.time = self.time + 1
self.display["text"] = str(self.time)
self.after(1000, self.loop)
win = Tk()
app = Clock(win)
app.run() #also tried run(win) with self,parent above
win.mainloop()
HTH.
--
------------------------------------------------------------------------
Miki Tebeka <miki.tebeka at zoran.com>
http://tebeka.bizhat.com
The only difference between children and adults is the price of the toys
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 193 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20050425/b28ba844/attachment.sig>
More information about the Python-list
mailing list