[Tutor] TKinter display dialog 2nd time?

Abel Daniel abli@freemail.hu
Fri Mar 21 01:53:02 2003


Bob Gailer wrote:
> One of the drawbacks of this approach is that a blank TK window opens in 
> the background, with the message box in a 2nd window. The blank window does 
> not go away until the program terminates. SIGH.

Try:

import Tkinter
import tkMessageBox

root_window=Tkinter.Tk()
root_window.withdraw()
tkMessageBox.showwarning('warn','danger')

The background of the problem is that tkMessageBox creates the dialogs
as the instances of the Toplevel class. The extra blank window comes
from the 'root window' (also a Toplevel) which you automatically get
when initializing tkinter. The above work-around works by hiding this
window as soon as it is made.

Abel Daniel