0

I happened to see (and isolate) the following problem and have 2 questions:
1) tkMessageBox is used extensively in my code. How do I make my code work without a significant re-write?
2) how do I tell the wonderful tkinter developers that there is a problem?

The problem is seen when running python 2.6.2 on Ubuntu 904. Interestingly the problem is not happening when using python 2.5.4 on WinXP.

The problem manifests as follows:

>>> import tkMessageBox
>>> tkMessageBox.askyesno() #user clicks "yes"
True
>>> import tkFileDialog
>>> tkFileDialog.askopenfilename() #user can do whatver - e.g. click "cancel"
''
>>> tkMessageBox.askyesno() #user clicks "yes"
False
>>>

digging into the source I tried this:

>>> import tkMessageBox
>>> res=tkMessageBox._show(_type="yesno") #user clicks "yes"
>>> res
u'yes'
>>> type(res)
<type 'unicode'>
>>> import tkFileDialog
>>> tkFileDialog.askopenfilename() #user clicks "cancel"
''
>>> res=tkMessageBox._show(_type="yesno") #user clicks "yes"
>>> res
<booleanString object at 0xa103790>
>>> print res
yes
>>> type(res)
<type '_tkinter.Tcl_Obj'>
>>>

Note that Python 2.5.4 on WinXP continues to return a string from tkMessageBox._show

The tkMessageBox.askyesno code executes the following, which fails when res is of type '_tkinter.Tcl_Obj':

From "/usr/lib/python2.6/lib-tk/tkMessageBox.py", line 74:

if isinstance(res, bool):
        if res: return YES
        return NO
    return res
2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by harishankar
0

I happened to see (and isolate) the following problem and have 2 questions:
1) tkMessageBox is used extensively in my code. How do I make my code work without a significant re-write?
2) how do I tell the wonderful tkinter developers that there is a problem?

The problem is seen when running python 2.6.2 on Ubuntu 904. Interestingly the problem is not happening when using python 2.5.4 on WinXP.

The problem manifests as follows:

>>> import tkMessageBox
>>> tkMessageBox.askyesno() #user clicks "yes"
True
>>> import tkFileDialog
>>> tkFileDialog.askopenfilename() #user can do whatver - e.g. click "cancel"
''
>>> tkMessageBox.askyesno() #user clicks "yes"
False
>>>

digging into the source I tried this:

>>> import tkMessageBox
>>> res=tkMessageBox._show(_type="yesno") #user clicks "yes"
>>> res
u'yes'
>>> type(res)
<type 'unicode'>
>>> import tkFileDialog
>>> tkFileDialog.askopenfilename() #user clicks "cancel"
''
>>> res=tkMessageBox._show(_type="yesno") #user clicks "yes"
>>> res
<booleanString object at 0xa103790>
>>> print res
yes
>>> type(res)
<type '_tkinter.Tcl_Obj'>
>>>

Note that Python 2.5.4 on WinXP continues to return a string from tkMessageBox._show

The tkMessageBox.askyesno code executes the following, which fails when res is of type '_tkinter.Tcl_Obj':

From "/usr/lib/python2.6/lib-tk/tkMessageBox.py", line 74:

if isinstance(res, bool):
        if res: return YES
        return NO
    return res

I've encountered the same problem and filed a bug report with Debian.

Hopefully the tkinter module will be fixed in the next minor update.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.