Tkinter tạo popup bằng messagebox. Cần import tkinter.messagebox. Popup hiển thị câu hỏi, xử lý theo lựa chọn.
Ví dụ
# Import thư viện
from tkinter import *
import tkinter.messagebox
# Tạo khung
win = Tk()
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()
# Nút mở popup
button = Button(win, text="Click Me", command=open_win, font=('Helvetica 14 bold'), foreground='OrangeRed3', background="white")
button.pack(pady=50)
win.mainloop()Kết quả
Hiển thị nút, click hiện messagebox hỏi Yes/No.


Chọn Yes hiển thị thông báo cảm ơn.
