[Tutor] Configuration File, Tkinter, IntVars--Manufacturing Variables

W W srilyk at gmail.com
Tue Mar 3 21:22:15 CET 2009

On Tue, Mar 3, 2009 at 1:54 PM, Wayne Watson
<sierra_mtnview at sbcglobal.net> wrote:
> BTW, the Quit function is original but doesn't kill the window when Quit is
> used. What fixes that? For more bonus points, it seems as though the try
> statement in the dialog should really bring up an "Error" dialog saying
> something is wrong, when an invalid entry occurs. No need to construct an
> error dialog for me, but I'd be curious how it might be handled.

For the error dialog you can easily use tkMessageBox:

just import tkMessageBox and then use this:

In [2]: tkMessageBox.showerror('Some Error', 'An Error occurred!')
Out[2]: 'ok'

If you're expecting a specific error you can use

    #some statements
except SpecificError:
    #Handle the error

In this case (at least the block I looked at) it's just printing to
the command line. You can handle it using any one of the message boxes
or creating your own.

>     def Quit(self):
>         self.running = False
>         self.master.quit()

You could also try self.master.destroy()

when I tried:

from Tkinter import *
root = Tk()

in an ipython session. It didn't close my root window but the destroy
method did.


More information about the Tutor mailing list