Tkinter Dialog Management problems:

Eric Brunel eric_brunel at
Thu May 18 16:56:13 CEST 2006

On Thu, 18 May 2006 08:41:20 -0400, Michael Yanowitz  
<m.yanowitz at> wrote:

> Hello:
>    Below I have included a stripped down version of the GUI I am working  
> on.
> It contains 2 dialog boxes - one main and one settings. It has the  
> following
> problems, probably all related, that I am hoping someone knows what I am
> doing wrong:
> 1) Pressing the Settings.. Button multiple times, brings up many  
> instances
>    of the Settings Panel. I just want it to bring up one. Is there an  
> easy
>    way to do that?

In fact, the two windows you created are not dialogs; they're just  
windows. To turn a window into an actual "dialog", i.e basically to make  
it modal, you have to do the following operations (supposing your dialog  
window is named dlg and your main window in named root):

## Ensure only window can receive user events
## Force Dialog to stay on top of main window
## Wait for dialog to be destroyed

> 2) Pressing the Done button in the Settings Panel, just erases the Done
> button
>    (and any other widgets in the Panel). It does not dismiss the Panel.
> Pressing
>    the X button does work. What callback is that? Can I make the Done  
> button
> call
>    that instead? How?

This is not the way it works. In fact, what you did wrong is something  
that has been around for years in some Tkinter tutorial(s): you made your  
classes inherit from Frame. This is a Bad Idea: a Frame is not a window,  
but only a generic container. There are 2 classes for windows: Tk for the  
main window and Toplevel for all others. They both also act as containers,  
so you can do in them everything you do in Frames. So make your  
ScriptDialog inherit from Tk, your SettingsDialog inherit from Toplevel,  
remove all explicit creations of Tkinter.Tk or Tkinter.Toplevel and  
instantiate your classes instead. Then calling destroy on either on the  
dialogs will actually close the window.

> 3) Pressing the Done button from the Main Panel has no effect? Why not?  
> It
> used
>    to work (self.quit()). Again, I would like to call whatever is called
> when the
>    X button (top Right corner) is pressed.

This should work. BTW, your "done" method is not needed: creating the  
Button with command=self.quit works without problem.

python -c "print ''.join([chr(154 - ord(c)) for c in  

More information about the Python-list mailing list