Tkinter에는 응용 프로그램의 내부 기능을 확장하는 데 사용할 수 있는 많은 내장 기능과 기능이 있습니다. Tkinter의 팝업은 메시지 상자를 정의하여 생성됩니다. 팝업 메시지 상자를 사용하려면 먼저 "import tkinter.messagebox 명령으로 Tkinter에서 메시지 상자 패키지를 가져와야 합니다. ".
예시
이 예에서는 질문이 있는 메시지 상자 팝업을 만듭니다. 특정 옵션을 클릭하면 사용자가 해당 작업으로 리디렉션됩니다.
# Import the required libraries
from tkinter import *
import tkinter.messagebox
# Create an instance of Tkinter Frame
win = Tk()
# Set the geometry of Tkinter Frame
win.geometry("700x350")
def open_win():
out = tkinter.messagebox.askquestion('Prompt', 'Do you want to Continue?')
if out == 'yes':
Label(win, text="Thank You for your Response!", font=('Helvetica 22 bold')).pack(pady=40)
else:
win.destroy()
# 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() 출력
위의 코드를 실행하면 다음 창이 표시됩니다 -

이제 "나를 클릭하십시오" 버튼을 클릭하십시오. 질문이 있는 메시지 상자가 표시됩니다.

그런 다음 메시지 상자에서 "예" 버튼을 클릭합니다. 다음 창이 표시됩니다 -
