OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Protocols in tkinter in Python

  • Thread starter Thread starter Python Learner
  • Start date Start date
P

Python Learner

Guest
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?

Code:
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()
<p>I am new in Python and I want to use protocols like <code>WM_DELETE_WINDOW</code>, <code>WM_TAKE_FOCUS</code> and <code>WM_SAVE_YOURSELF</code>. I have found an example of <code>WM_DELETE_WINDOW</code> which is clear enough to understand. But I want to understand the rest two protocols. What do they do?</p>
<pre><code>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()
</code></pre>
 
Top