[Tkinter-discuss] toplevel on top

Michael Lange klappnase at web.de
Mon Apr 10 11:40:57 CEST 2006


On Sun, 09 Apr 2006 07:41:25 +0200
Pavel Kosina <geon at post.cz> wrote:

> 
> I am afraid it doesnt work, at least as I can understand it. I still can 
> activate the root window.
> 
> from Tkinter import *
> 
> def OK():
>     top=Toplevel(root)
>     top.transient(root)
>     top.focus()
>     helpText=Label(top,text="Help")
>     helpText.pack()
>     top.mainloop()
> 
> 
> root=Tk()
> helpButton=Button(text="Help", command=OK)
> helpButton.pack()
> 
> root.mainloop()
>    

Hi Pavel,

transient() only makes the Toplevel stay on top of the root window, if you do not want
the root window to receive any events you need to call grab_set(), too:

    top.transient(root)
    top.grab_set()

HTH

Michael


More information about the Tkinter-discuss mailing list