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?

Answer

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()
window.title("Example")
window.state("zoomed")


def protocol_handler():
    # code


window2 = tk.Toplevel(window)
window2.geometry("300x220+500+200")
label1 = tk.Label(window2, text="Would you like to continue?")
label1.place(x=20, y=10)
button1 = tk.Button(window2, text="Yes")
button1.place(x=50, y=100)
button2 = tk.Button(window2, text="No")
button1.place(x=100, y=100)

window2.protocol("WM_DELETE_WINDOW", protocol_handler)


window.mainloop()