[Tutor] a question related to modal in Tkinter

Magnus Lycka magnus@thinkware.se
Tue Jan 21 08:19:01 2003


At 02:58 2003-01-21 +0000, Hy Python wrote:
>How can I make some a Toplevel object a REAL modal window?

I think you've misunderstood how to use .wait_window(). Also,
the new windows should (I guess) have a parent that still lives
when you close the modal. (Otherwaise you can never use them.)
Finally, .lower() is useful.

Did you mean like this?

from Tkinter import *

def showWindow(master):
    myToplevel=Toplevel(master)
    Label(myToplevel, text="MY MAIN TOPLEVEL WINDOWS").pack()
    Button(myToplevel, text="CLICK", command=(lambda
      myToplevel=myToplevel:showMoreWindow(master, myToplevel)
      )).pack()
    master.wait_window(myToplevel)

def showMoreWindow(master, modal):
    x = Toplevel(master)
    x.lower(modal)
    x.wait_window(modal)

root=Tk()
Button(root, text="HI", command=(
   lambda root=root:showWindow(root))).pack()
root.mainloop()


-- 
Magnus Lycka, Thinkware AB
Alvans vag 99, SE-907 50 UMEA, SWEDEN
phone: int+46 70 582 80 65, fax: int+46 70 612 80 65
http://www.thinkware.se/  mailto:magnus@thinkware.se