Tkinter 최상위 클래스에 최상위 가 포함됨 메인 윈도우가 아닌 자식 윈도우인 윈도우. 최상위 창을 만들 때마다 기본 창 위에 정의된 위젯과 함께 표시됩니다.
창 최상위 창에 포커스를 유지하려면 grab_set()를 사용할 수 있습니다. 방법. 항상 다른 모든 창보다 최상위 창을 유지합니다.
예
#Import the tkinter library
from tkinter import *
#Create an instance of tkinter frame
win = Tk()
win.geometry("700x350")
def open_win():
top = Toplevel(win)
top.geometry("700x250")
Label(top, text= "Hey Folks!", font= ('Helvetica 14 bold')).pack()
top.grab_set()
#Create a Label to print the Name
label= Label(win, text="Click the below Button to open the Popup", font= ('Helvetica 18 bold'))
label.pack(pady= 30)
#Create a Button
button= Button(win, text= "Click Me", command= open_win, font= ('Helvetica 14 bold'), foreground= 'OrangeRed3', background= "white")
button.pack(pady=50)
win.mainloop() 출력
위의 코드를 실행하면 팝업 창을 여는 버튼이 포함된 창이 표시됩니다.

이제 버튼을 클릭하여 팝업창을 엽니다.
