Tkinter: modal ok in windows, but not in Linux

klappnase klappnase at web.de
Fri Jan 16 06:53:17 EST 2004


DoubleM <mmoum at woh.rr.com> wrote in message news:<NWkNb.2858$fU.1773 at fe2.columbus.rr.com>...
> Hi,
> 
> I'm running Python2.3.3c1 on Mandrake 9.1
> 
> The following code is designed to bring up a window with a button labeled
> "popup".  Clicking on the popup buttons triggers a secondary window with a
> button labeled "ok".  The second window is supposed to be modal - it should
> not be possible to reset the focus back to the first window or close the
> first window without first closing the second.  The program works just fine
> in Windows XP home, but in Linux I can close the first window while the
> second one is still active.
> 
> This seems to be a bug, or am I doing something wrong.  I searched google
> for Tkinter Linux modal, but found nothing relevant.
> 
> Thanks for your help.
> 
> Here's the code, copied and pasted from IDLE.
> 
> #############################
> from Tkinter import *
> 
> makemodal = 1
> 
> def dialog():
>     win = Toplevel()
>     Label(win, text = "Secondary").pack()
>     Button(win, text = "Ok", command = win.destroy).pack()
>     if makemodal:
>         win.focus_set()
>         win.grab_set()
>         win.wait_window()
>     print "dialog exit"
> 
> root = Tk()
> Button(root, text = 'popup', command = dialog).pack()
> root.mainloop()
> #################################
> 
> Mike
> mmoum-xxxspam.woh.rr.com

Hi Mike,

I guess you should use

    root.wait_window(win)

instead of
 
    win.wait_window()

Cheers

Michael



More information about the Python-list mailing list