From: aa8vb at vislab.epa.gov (Randall Hopper)
Date: Fri, 16 Apr 1999 18:48:31 GMT
Subject: Tkinter - the app that wouldn't quit
Message-ID: <19990416144831.A1548022@vislab.epa.gov>
Content-Length: 1085
X-UID: 835                                                  

     I'm writing a test wrapper for a dialog module that doesn't terminate
the application.  How can I exit the test program when the dialog is
dismissed?

     Attached is a minimal version that illustrates the problem.  When it
self.destroy()'s itself, we're hung.  mainloop() is still spinning.
As you can see, I did try WM_DELETE_WINDOW.

Thanks for any tips,

Randall

-------------- next part --------------
#!/usr/bin/env python

import sys
from Tkinter import *
from ScrolledText import ScrolledText

class CommandWindow(ScrolledText):

    def __init__(self, master=None, **cnf):
        apply(ScrolledText.__init__, (self, master), cnf)

class CommandWindowDialog(Toplevel):

    def __init__(self, master=None, **cnf):
        apply(Toplevel.__init__, (self, master), cnf )
        self.title( 'COMMAND OUTPUT' )
        win = CommandWindow( self )
        win.pack(expand=1, fill=X)
	btn = Button( self, text="Quit", command=self.destroy )
	btn.pack()

root = Tk()
w = CommandWindowDialog( root )
w.protocol( 'WM_DELETE_WINDOW', sys.exit )
root.wm_withdraw()
w.mainloop()


