1 ##transient is only part of the solution. You also want to set the grab on the
   2 ##secondary window, and then wait for the secondary window to close.
   3 ##So this is the magical sequence to make a window modal in Tkinter: 
   4 ##transient, grab_set, wait_window. -Eric Brunel
   5 
   6 from Tkinter import *
   7 
   8 root = Tk()
   9 
  10 def go():
  11    wdw = Toplevel()
  12    wdw.geometry('+400+400')
  13    e = Entry(wdw)
  14    e.pack()
  15    e.focus_set()
  16    wdw.transient(root)
  17    wdw.grab_set()
  18    root.wait_window(wdw)
  19    #print 'done!'
  20 
  21 Button(root, text='Go', command=go).pack()
  22 Button(root, text='Quit', command=root.destroy).pack()
  23 
  24 root.mainloop()

tkinter: ModalWindow (last edited 2011-07-01 05:41:26 by AnthonyMuss)