faqts : Computers : Programming : Languages : Python : Tkinter

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

23 of 25 people (92%) answered Yes
Recently 8 of 10 people (80%) answered Yes

Entry

How can I create a Tkinter MessageBox with the MessageBox - option "YESNOCANCEL"?

May 27th, 2000 20:37
unknown unknown, Robert Roy


Problem:

When I use -

import tkMessageBox
tkMessageBox.askquestion("equal","even better", icon=QESTION,
type=YESNOCANCEL)

The error message here is: NameError: QUESTION

Solution:

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)