simple Tkinter question

John Michelsen john.michelsen at gte.net
Sat May 29 15:49:40 EDT 1999


You need a root window even if you don't use it.
You could root.withdraw() it so that it's not visible.

from Tkinter import *
import tkMessageBox

root = Tk()
root.withdraw()
result = tkMessageBox.askyesno()
root.destroy() # when you want to exit
root.mainloop()

John

Tom Adelman wrote in message <374F4466.6F9015B7 at cornell.edu>...
>    I've just started to work with Tkinter and am having some trouble.
>In interactive mode I type
>
>import tkMessageBox
>tkMessageBox.askyesno()
>
>When this runs it pops up two windows, an empty tk window and the yes/no
>dialog.  My problem is the empty tk window.  If ever I close this tk
>window I can never run tkMessageBox.askyesno() again, or I get the
>traceback,
>
>Traceback (innermost last):
>  File "<pyshell#13>", line 1, in ?
>    tkMessageBox.askyesno()
>  File "D:\Program Files\python\Lib\lib-tk\tkMessageBox.py", line 100,
>in askyesno
>    s = apply(_show, (title, message, QUESTION, YESNO), options)
>  File "D:\Program Files\python\Lib\lib-tk\tkMessageBox.py", line 75, in
>_show
>    return apply(Message, (), options).show()
>  File "D:\Program Files\python\Lib\lib-tk\tkCommonDialog.py", line 49,
>in show
>    w = Frame(self.master)
>  File "D:\Program Files\python\Lib\lib-tk\Tkinter.py", line 1406, in
>__init__
>    Widget.__init__(self, master, 'frame', cnf, {}, extra)
>  File "D:\Program Files\python\Lib\lib-tk\Tkinter.py", line 1084, in
>__init__
>    self.tk.call(
>TclError: can't invoke "frame" command:  application has been destroyed
>
>
>    Thanks for any advice.
>    Tom
>
>
>






More information about the Python-list mailing list