Tkinter- Building a message box

Ron Adam rrr at ronadam.com
Mon Nov 7 13:40:50 EST 2005


Tuvas wrote:
> I've been trying to build a fairly simple message box in tkinter, that
> when a button is pushed, will pop up a box, that has a line of text, an
> entry widget, and a button, that when the button is pushed, will return
> the value in the line of text. However, while I can read the value of
> the button, I want to wait till the button is pushed to return the
> value. Any ideas of how I could do this?

The way I do it is to set self.result in the dialog to the return value 
just before closing and exiting.

And then instead of openiug the dialog directly I use a function to pass 
and sometimes modify the values to the dialog and then return the 
dialog.result value after it's closed.

Something like...

def domydialog(*args, **kwds):
    #
    # Check and modify args or kwds here if needed.
    #
    mydialog(*args, **kwds)
    return mydialog.result

Cheers,
    Ron




More information about the Python-list mailing list