[Tkinter-discuss] Re: making tkFileDialog and tkMessageBox modal on Win32

Michael Lange klappnase at web.de
Wed Apr 6 21:33:03 CEST 2005

On Wed, 6 Apr 2005 11:04:50 -0700
"Greg Lee" <glee at pharsight.com> wrote:

> The esteemed Fredrik Lundh responded:
> > well, they sure are modal on my machine.  maybe you could post an example, tell
> > us how it behaves on your machine, and tell us how you expected it to behave.
> I, too, have seen the file dialogs behave modally on my machine---but not always.
> This following has a top-level window with a menu item that launches a child.  The child has two browse buttons.  On my machine I can use the browse buttons to bring up about eleven simultaneous file dialogs.  What I had hoped for was that the first file dialog to appear would be modal, i.e. the browse buttons would be inactive until the file dialog was dismissed.
> --------------------------------------------
> import os
> import Tkinter
> import tkMessageBox
> import tkFileDialog
> import sys
> # constants for NewPhx widgets
> class NewPhx:


On my box (linux) the file dialog is modal, however because you didn't specify a parent to the file  dialog
it's modal to the root window and not to the child-toplevel, so I can lift the toplevel over the file dialog,
but as expected the toplevel's buttons do not respond. Maybe it's a system/Tk-version problem that the grab
doesn't work for you? Anyway, you could try to pass "parent=self.top" to askopenfilename() and see what happens.

I hope this helps


More information about the Tkinter-discuss mailing list