2010-06-02 3 views

답변

4

창이 파괴되면 시작되는 바인딩을 설정할 수 있습니다. <Destroy>에 바인딩하거나 WM_DELETE_WINDOW에 대한 프로토콜 처리기를 추가하십시오. 예를 들어

: 특정 위젯이 파괴 될 때 액션이 발생 할 경우, 당신은 파괴() 메서드를 재정 고려할 수

def callback(): 
    # your cleanup code here 

... 
root.protocol("WM_DELETE_WINDOW", callback) 
3

. 프레임 (F) '는'B1 '및 아이, 파괴', B2 '버튼을 누르면

class MyButton(Tkinter.Button): 
    def destroy(self): 
     print "Yo!" 
     Tkinter.Button.destroy(self) 

root = Tkinter.Tk() 

f = Tkinter.Frame(root) 
b1 = MyButton(f, text="Do nothing") 
b1.pack() 
f.pack() 

b2 = Tkinter.Button(root, text="f.destroy", command=f.destroy)   
b2.pack() 

root.mainloop() 

다음 예를 참조 "요!" 인쇄됩니다.

관련 문제