How do I prevent master window from being accessed with childwindow present?

Michael Peuser mpeuser at web.de
Sat Aug 30 04:01:49 EDT 2003


"Marc" <losnations at comcast.net> schrieb im Newsbeitrag
news:7YadnTLIALoMddKiXTWJiw at comcast.com...
> I guess knowing which kit would help. I am using Tkinter.
>
Of course you were usind Tkinter...

(1) You can use the modal approach (have a look how Pmw are doing this.
(2) Disable all your controls in the main widget when you show the child
window.
(3) "withdraw" the main window (this is not iconify!)

Example:
from Tkinter import *

m=Tk()
m.title("Parent")
c=Toplevel(m)
c.title("Child")
Button(c,text="Hello",command=c.destroy).pack()

c.bind("<Destroy>",lambda x:m.deiconify())
# note we need lambda to get rid of the Destroy argument
#we should "bind", because there are many ways a window can be killed

m.withdraw()

mainloop()







More information about the Python-list mailing list