[Tkinter-discuss] Dialog and mainloop (UNCLASSIFIED)
Gerardo Juarez
gerardo at computo-industrial.com.mx
Sun Jul 15 21:41:49 CEST 2007
Use a Toplevel window, display your dialog there and add a button whose
command is "withdraw". Like this:
def winmsg(s):
w = Toplevel()
Label(w, text=s, relief='groove').pack(padx=10, pady=5)
Button(w, text='Ok', command=w.withdraw).pack(pady=5)
Every time I call winmsg() with a message I wish to display, the popup
dialog appears. When the user reads the message and presses the button,
the popup is immediately gone. I think this is what you want.
Note that this simple dialog is not modal, but that's a problem you may
run into further down the line, certainly not now.
Gerardo
On Fri, 13 Jul 2007, Hensley, Jeffrey L ERDC-ITL-MS Contractor wrote:
> Classification: UNCLASSIFIED
> Caveats: NONE
>
> I have an application in the works but seem to have a basic misunderstanding
> of the implementation of standard dialog windows.
>
> When the user presses a button to commit an action, I wish to pop up a dialog
> with a "Are you sure?" query. I'm trying to use the basic askyesno. If the
> user chooses to continue, we go on our merry way and processing occurs
> (potentially very time consuming).
>
> HOWEVER, even though the user has pressed "yes" or "no", the dialog window
> itself does not disappear until I fall out of the function and, I believe,
> the process has returned to the mainloop.
>
> The behavior I have now is, well, unacceptable. The underlying processing may
> take some time, there are messages being written to a status window, etc; and
> the user is stuck looking at the dialog not aware of what is going on.
>
> Am I missing something? [well, of course I am!]
>
> Suggestions/comments?
>
> **************************************************************
> Jeff Hensley, Ph.D. Phone: 601-634-4596
> EQM On-site lead, ERDC PET Fax: 601-634-2324
> 3909 Halls Ferry Road Jeffrey.L.Hensley at erdc.usace.army.mil
> Vicksburg, MS 39180-6199 http://www.erdc.hpc.mil
> **************************************************************
>
> Classification: UNCLASSIFIED
> Caveats: NONE
>
> _______________________________________________
> Tkinter-discuss mailing list
> Tkinter-discuss at python.org
> http://mail.python.org/mailman/listinfo/tkinter-discuss
>
More information about the Tkinter-discuss
mailing list