#AssessmentGUI
from Tkinter import *
window=Tk()
window.title('Troubleshooting')
def start():
wet()
def wet():
global wetlabel
wetlabel=Label(window, text="Has the phone got wet? Y/N")
wetsubmit()
def wetsubmit():
wetlabel.pack()
wetanswer=(entry.get())
if wetanswer=="Y":
print"ADD SOLUTION"
else:
dropped()
def dropped():
global droppedlabel
dropwindow.title('Troubleshooting')
dropwindow.mainloop()
droplabel=Label(dropwindow, text="Has the phone been dropped? Y/N")
droplabel.pack()
dropButton.pack()
dropsubmit()
def dropsubmit():
print "test"
window.geometry("300x100")
global wetsubmit
Button=Button(window, text="Submit Answer", activebackground="Green",command= wetsubmit , width=100)
dropwindow=Tk()
dropButton=Button(dropwindow, text="Submit Answer", activebackground="Green",command= dropsubmit , width=100)
entry=Entry(window, text="Test", width=100)
start()
entry.pack()
Button.pack()
window.mainloop()
以上是我的代码因错误而无法正常工作。基本上我想要发生的是每个窗口打开另一个窗口后面的故障排除程序的下一个问题!如果任何人有任务,如果你可以建议一个更好的方法,如果我的不可修复将是很好的。 错误消息显示:
Traceback (most recent call last):
File "H:\GCSE\Computing\GUI.py", line 36, in <module>
dropButton=Button(dropwindow, text="Submit Answer", activebackground="Green",command= dropsubmit , width=100)
AttributeError: Button instance has no __call__ method*
这是在对原始代码进行一些调整之后,但我无法解决这个问题!
答案 0 :(得分:1)
您有一个名为Button
的类,然后您创建一个名为Button
的变量。您现在已经销毁了该类,因此下次尝试创建按钮时,您将调用您的变量。
课程:不要使用与类相同的变量名。