how to handle the “delete window” protocol on messageboxes- Python tkinter

Let’s say I have a message box in Python tkinter, for example:

from tkinter import messagebox
messagebox.showinfo("Example", "This is an example")

I want to be able to handle the message box’s closing protocol. I know you can do it with tkinter windows, like so:

window.protocol("WM_DELETE_WINDOW", on_closing)

But my question is how do you do it with message boxes?


I figured out that what I wanted to do isn’t possible (with the help of @Matiiss). So what I did instead was I created a toplevel widget, added buttons to it and handled its closing protocol. Example:

import tkinter as tk
from tkinter import messagebox

window = tk.Tk()

def protocol_handler():
    # code

window2 = tk.Toplevel(window)
label1 = tk.Label(window2, text="Would you like to continue?"), y=10)
button1 = tk.Button(window2, text="Yes"), y=100)
button2 = tk.Button(window2, text="No"), y=100)

window2.protocol("WM_DELETE_WINDOW", protocol_handler)