[Python] Protocols in tkinter in Python

Discussão em 'Python' iniciado por Stack, Fevereiro 15, 2025.

  1. Stack

    Stack Membro Participativo

    I am new in Python and I want to use protocols like WM_DELETE_WINDOW, WM_TAKE_FOCUS and WM_SAVE_YOURSELF. I have found an example of WM_DELETE_WINDOW which is clear enough to understand. But I want to understand the rest two protocols. What do they do?

    from Tkinter import *
    import tkMessageBox

    root = Tk()

    def on_closing():
    if tkMessageBox.askokcancel("Quit", "Do you want to quit?"):
    root.destroy()

    root.protocol("WM_DELETE_WINDOW", on_closing)

    root.mainloop()

    Continue reading...

Compartilhe esta Página