Jump to content
Chained/Nested Modal windows in Python tkinter
Asked by mhalverson
Posted Feb 01 2011 11:06 AM
I'm creating a python application (I'm using 3.1.3) that will have a gui built using tkinter. I'm trying to get multiple modal windows that should be chained together ie The first window is inoperable until the second window is closed and the second window is inoperable until the third is closed. The behavior seems to be ok when the three windows are on screen. The problem is that when I close the third window, the first becomes responsive again, and no longer waits for the second. I am almost certain that there are some events bubbling up somewhere causing this (had this problem before), but I am not sure how to fix this. I have attached a very simple stripped down version of how my application does this (it seems the site is screwing up my indentation - there is no problem there). By pressing the slave button on the first window, a second is opened and pressing its slave creates a third. These should be chained like I described above.
from tkinter import *
Button(win,text="Slave",command=(lambda self=win: makeModal(self))).pack()
Button(root,text="Slave",command=(lambda self=root: makeModal(self))).pack()