TkMessageBox

Robert Roy rjroy at takingcontrol.com
Sat May 27 11:56:27 EDT 2000


On Sat, 27 May 2000 09:48:32 +0200, "Ralf Claus"
<ralf.claus at t-online.de> wrote:

>Hi,
>i try to create a Tkinter MessageBox with the MessageBox - option
>"YESNOCANCEL"
>But what ever i try, it does not work.
>
>In my opinion the syntax must look like this:
>
>import tkMessageBox
>tkMessageBox.askquestion("equal","even better", icon=QESTION,
>type=YESNOCANCEL)
>
>The error message here is: NameError: QUESTION
>
>but why ?
>
>Ralf
>

QUESTION is not in your namespace
try
tkMessageBox.askquestion("equal",
	"even better",
	 icon=tkmessageBox.QUESTION, 
	type=tkMessageBox.YESNOCANCEL)

however this will bring up another a type error: 
	keyword parameter redefined.

so then instead of using askquestion use _show

tkMessageBox._show("equal",
	"even better",
	 icon=tkmessageBox.QUESTION, 
	type=tkMessageBox.YESNOCANCEL)


If you look at the sources you will see that askquestion is just a
shortcut for

 _show(title, message, icon, type) where icon=QUESTION and type=YESNO
 
ref:
def askquestion(title=None, message=None, **options):
    "Ask a question"
    return apply(_show, (title, message, QUESTION, YESNO), options)


Bob



More information about the Python-list mailing list