【发布时间】:2017-12-02 21:16:42
【问题描述】:
我正在尝试向两个已经存在的按钮添加第三个按钮。但总是收到错误消息,不知道出了什么问题。
Import Tkinter as tki
btn = tki.Button(self.root, text="yes!", command=self.yes, fg="black", bg="white", font=("Courier", 22))
btn.grid(row=4, column=1, padx=10, pady=10, sticky="NSEW" )
btn2 = tki.Button(self.root, text="No!", command=self.no, fg="black", bg="white", font=("Courier", 22))
btn2.grid(row=4, column=0, padx=10, pady=10, sticky="NSEW")
btn3 = tki.Button(self.root, text="HELP", command=self.help, fg="black", bg="white", font=("Courier",22))
btn3.grid(row=5, column=0, padx=10, pady=10, sticky="NSEW" )
self.w = tki.Canvas(self.root,width=48,height=48, bg="white")
self.w.grid(row=3,column=0,columnspan=3)
self.circle = self.w.create_oval(2,2,48,48,fill="white")
不,是的,帮助在代码中实现。不,是的,一切正常。但现在我总是得到一个 IndentationError: unexpected indent。 你能帮帮我吗?
【问题讨论】:
-
您分享的代码不完整。
self. w和self. circle应该在一个类中 -
什么是缩进错误?
-
我知道代码不完整,只是为了告诉你问题是什么。
-
问题出在您未共享的代码中。
-
你能提供(至少)完整的错误信息吗?如果我们不知道错误是什么以及导致它的原因,我们就无法诊断错误。
标签: python button canvas tkinter