By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,248 Members | 882 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,248 IT Pros & Developers. It's quick & easy.

Tkinter- Building a message box

P: n/a
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?

Nov 7 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a

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

Nov 7 '05 #2

P: n/a
Do you have any info on dialogs? I've been trying to find some, without
alot of success...

Nov 7 '05 #3

P: n/a
Maybe this can help:
http://effbot.org/zone/tkinter-dialog-windows.htm

Good luck!

Nov 7 '05 #4

P: n/a
Thanks alot, that helped TONS! Just had to modify it slightly, but,
well, it works great now. Thanks!

Nov 7 '05 #5

P: n/a


Tuvas wrote:
Do you have any info on dialogs? I've been trying to find some, without
alot of success...


Be sure and look at the examples in python24/lib/lib-tk. The Dialog.py
file there does pretty much what you want.

In the dialog caller example I gave, it should have been ...

def domydialog(*args, **kwds):
#
# check or change args or kwds
#
d = mydialog(*args, **kwds)
return d.result

I left out the returned object name 'd'. Which is needed to get the
result from the dialog instance.

Cheers,
Ron


Nov 7 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.