Exception in Tkinter callback Traceback (most recent call last): File "C:\Python26\lib\lib-tk\Tkinter.py", line 1410, in __call__ return self.func(*args) File "C:\module1.py", line 25, in countdown if self.time == 0: AttributeError: App instance has no attribute 'time'
入力したソースは以下の通りです。
#!/c/python26/phthon # -*- coding: shift_jis -*- from Tkinter import * import time
class App(Frame): TIME = 60*3 def __init__(self, master=None): " 初期化の設定 " Frame.__init__(self, master) self.master.title("Tk Timer") self.timestr = StringVar() self.timestr.set("03:00") l = Label(self,textvariable=self.timestr, font=('Helvetica','48','bold')) b1 = Button(self,text="Start",command=self.countdown) b2 = Button(self,text="Quit", command=self.master.destroy) for obj,sideparam in ((l,TOP),(b1,LEFT),(b2,RIGHT)): obj.pack(side=sideparam) self.pack()