2016-09-19 4 views
0
#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() 

위의 코드는 오류로 인해 작동하지 않습니다. 기본적으로 내가 원하는 것은 각 윈도우가 문제 해결 프로그램의 다음 질문을 위해 다른 윈도우를 연다는 것입니다. 누구든지 작업이 있다면 내 것이 고칠 수 없다면 더 나은 방법을 제시 할 수 있다면 좋을 것입니다. 오류 메시지가 말한다 :단추 인스턴스에 _call_ 메서드가 없습니다.

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

여전히 같은 오류를 반환합니다. –

+0

안녕하세요. 도움을 받으신 후 게시물을 부인하지 마십시오. 그것은 아래의 대피소를 가져간 후 나무를 자르는 것과 같습니다. 다른 미래의 사용자가 그 지식으로부터 얻도록하십시오. 응답자는 많은 노력을 기울였습니다. 귀중한 시간을 낭비하지 마십시오. –

+2

질문을 파기하지 마십시오. –

답변

1

클래스 이름이 Button이고 Button이라는 변수를 만들었습니다. 이제 클래스를 삭제 했으므로 다음 번에 버튼을 만들려고하면 변수를 대신 호출합니다.

수업 : 수업과 같은 변수 이름을 사용하지 마십시오.

관련 문제