Alex Mantle
Alex Mantle

Reputation: 1

Button instance has no _call_ method

    #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()

Above is my code which isn't working due to the error. Basically what I want to happen is that each window opens another window after it for the next question on the troubleshooting program! If anyone has the task it would be nice if youy could suggest a better method if mine is unfixable. The error message says:

    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*

This is after a little bit of tweaking to the original code but I cannot fix this problem!

Upvotes: 0

Views: 243

Answers (1)

Bryan Oakley
Bryan Oakley

Reputation: 386342

You have a class, named Button,and then you create a variable named Button. You have now destroyed the class, so the next time you try to create a button, you are calling your variable instead.

Lesson: don't use variable names that are the same as classes.

Upvotes: 1

Related Questions