Fixing Leo and Idle OS shutdown bug?

DIG dig.list at telkel.net
Wed Aug 7 16:10:40 EDT 2002


Hi, Edward K. Ream !

 On Wed, Aug 07, 2002 at 02:30:42PM +0000, Edward K. Ream wrote:

> Leo does not prompt the user to save unsaved files when Windows 2K or XP is
> shutting down.  Neither does IDLE.
> 
> Is there any way to interrupt the shutdown process in TK?  I have tried
> binding to Destroy or WM_DELETE_WINDOW for the top level window, like this,
> with no effect:
> 
> root.bind("<Destroy>", onKillLeoEvent)
> root.protocol("WM_DELETE_WINDOW", onKillLeoEvent)
> root.mainloop()
> 
> Heck, this code doesn't even fire when I close Leo the regular way.
> 
> Does anyone know of a way to get the job done?  Thanks.

This works for me (linux 2.2.16, python 1.5.2):

                        --- 8< --- --- 8< --- --- 8< ---
#! /usr/bin/env python

# File: wm-close.py

import Tkinter
tk=Tkinter
import tkMessageBox


def on_close( ):
    if tkMessageBox.askokcancel( "Quit", "I am about to quit." ):
        root.destroy( )

root = tk.Tk( )
root.protocol( "WM_DELETE_WINDOW", on_close )

root.mainloop( )

                        --- >8 --- --- >8 --- --- >8 ---


Regards,

-- 
DIG (Dmitri I GOULIAEV)




More information about the Python-list mailing list