본문 바로가기
파이썬

파이썬 In Tkinter is there any way to make a widget not visible?

by º기록 2020. 11. 2.
반응형

다음과 같이 위젯이 정상적으로 표시됩니다.

Label(self, text = 'hello', visible ='yes') 

이와 같은 경우 위젯이 전혀 표시되지 않습니다.

Label(self, text = 'hello', visible ='no') 

 

해결 방법

 


from Tkinter import *

def hide_me(event):
    event.widget.pack_forget()

root = Tk()
btn=Button(root, text="Click")
btn.bind('<Button-1>', hide_me)
btn.pack()
btn2=Button(root, text="Click too")
btn2.bind('<Button-1>', hide_me)
btn2.pack()
root.mainloop()

 

참조 페이지 https://stackoverflow.com/questions/3819354

 

 

반응형

댓글