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

Greg Lee glee at pharsight.com
Fri Apr 8 02:52:57 CEST 2005


jepler's suggestion seems to solve the problem:

# Wrap a dialog in a grab pair.
# Use to make tkFileDialog and tkMessageBox application-modal.
# Not needed for tkSimpleDialog.
# tk - grab target
# f - tkFileDialog.askopenfilename, tkMessageBox.showinfo, etc.
# kw - dictionary of key-word arguments to f
def wrapgrab(tk, f, kw):
    kw['parent'] = tk
    tk.grab_set()
    retval = f(**kw)
    tk.grab_release()
    return retval

thanks,
greg

ps: is the need to use the grab function a bug or something 
I should have expected?



More information about the Tkinter-discuss mailing list