[Tkinter-discuss] Running GUI from console and quitting it

David Linke davidlinke at tiscali.de
Thu Jan 31 09:48:19 CET 2008


Amit Finkler wrote:
> Hi all,
(...)
> However, once the user presses the OK button, the root Tk() window
> remains. Note that in no place in the code did I create a Tk() instance.
> The only Tkinter instance is the MessageBox.
> 
> Is it possible to run some console-based script which pops-up a GUI
> window and then by pressing OK just kill/destroy it?

Just create the root window yourself to have control over it and withdraw it:

from Tkinter import *
import tkMessageBox
r = Tk()
r.withdraw()
tkMessageBox.showwarning(
                "Output check",
                "Output is not on")
a= raw_input('hit key to continue')

Regards,
David



More information about the Tkinter-discuss mailing list