首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > perl python >

python tk 的奇怪异常

2013-10-05 
python tk 的奇怪错误class Application(tk.Frame):def __init__(self,masterNone):tk.Frame.__init__(se

python tk 的奇怪错误


class Application(tk.Frame):
def __init__(self,master=None):
tk.Frame.__init__(self,master)
self.pack()
self.createWidgets()

def createWidgets(self):

self.end=tk.Button(self,text="end",fg="red",command=self.end)
self.end.pack(side="bottom")

self.start=tk.Button(self)
self.start["text"]="start"
self.start["command"]=self.start
self.start.pack(side="top")


def start(self):
print("start button clicked!")
def end(self):
print("end button clicked!")

root=tk.Tk()
app=Application(master=root)
app.mainloop()

点击start不管用,但是把start改成start1就能用了
本来猜测类本身有start函数 但是自己简单测试发现没有
请大家帮帮忙 python 类 tk
[解决办法]
命名不妥发生覆盖,self.start,self.end不可能同时是按钮控件,又是回调函数,改名字是必须的...

热点排行