classification
Title: Inconsistent/wrong result of askyesno function in tkMessageBox
Type: behavior Stage: patch review
Components: Tkinter Versions: Python 3.0, Python 3.1, Python 2.7, Python 2.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: doko, eb303, gpolo, kvander11
Priority: normal Keywords: patch

Created on 2009-01-16 09:38 by eb303, last changed 2010-03-20 02:20 by doko. This issue is now closed.

Files
File name Uploaded Description Edit
dialog-bug.py eb303, 2009-01-16 09:38
stringify.diff gpolo, 2009-06-21 21:41
Messages (7)
msg79944 - (view) Author: (eb303) Date: 2009-01-16 09:38
Scenario to reproduce the problem:
- Run the attached script.
- Click the 'Ask confirm' button and answer 'Yes'; it should print 
True, which is the expected answer.
- Click the 'Ask file' button, select any file and confirm.
- Click the 'Ask confirm' button and answer 'Yes'.
The script prints False, which is obviously wrong.
Problem reproduced on Linux Red Hat Fedora Core 4, Suse Enterprise 
Linux 9, Solaris 8 for Sparc and Solaris 10 on Intel. The script works 
as expected on Windows 2000, so it seems to be Unix-specific.

Possible cause: the result of the _show function in tkMessageBox is not 
always a string, apparently depending on what happened before. Changing 
the last line to:
return str(res)
seemed to correct the problem for me.
msg86345 - (view) Author: Guilherme Polo (gpolo) * (Python committer) Date: 2009-04-22 23:29
I've verified it, it is indeed a bug in tkMessageBox.py which is very
likely to be noticed while using tk 8.5 or newer.
msg89584 - (view) Author: Guilherme Polo (gpolo) * (Python committer) Date: 2009-06-21 21:41
I guess this will have to be accepted without any tests, unless someone
can come up with a way to test tk_messageBox under Windows and Mac.
msg97610 - (view) Author: Kirk Vander Meulen (kvander11) Date: 2010-01-11 22:20
I've also confirmed this one (by chance).  I'm on ubuntu linux, and I am seeing the problem in both 2.6 and 3.1, both using Tk 8.5.  I don't see the problem on my windows install (Vista, python 2.5, not sure of the Tk version right now).  But I did find a hack around this by explicitly creating and destroying a top level window following the askdirectory() dialog.  Try this snippet on linux/unix, the call to askyesno() returns False always.

import tkFileDialog,tkMessageBox,Tkinter
theDirectory=tkFileDialog.askdirectory()
addDirectory=tkMessageBox.askyesno('a dialog','Add a directory?')
print addDirectory


But the following works fine:

import tkFileDialog,tkMessageBox,Tkinter
toplevel=Tkinter.Tk()
theDirectory=tkFileDialog.askdirectory()
toplevel.destroy()
addDirectory=tkMessageBox.askyesno('a dialog','Add a directory?')
print addDirectory
msg101159 - (view) Author: Matthias Klose (doko) * (Python committer) Date: 2010-03-16 10:14
the patch works for me with tcl8.5
msg101160 - (view) Author: Matthias Klose (doko) * (Python committer) Date: 2010-03-16 10:54
fixed for 2.7, 3.1, 3.2, commit pending for 2.6 until after the 2.6.5 release
msg101356 - (view) Author: Matthias Klose (doko) * (Python committer) Date: 2010-03-20 02:20
committed to the 2.6 branch as well
History
Date User Action Args
2010-03-20 02:20:21dokosetstatus: pending -> closed
assignee: gpolo ->
messages: + msg101356
2010-03-16 10:54:40dokosetstatus: open -> pending
resolution: fixed
messages: + msg101160
2010-03-16 10:14:10dokosetnosy: + doko

messages: + msg101159
stage: test needed -> patch review
2010-01-11 22:20:25kvander11setnosy: + kvander11
messages: + msg97610
2009-06-21 21:41:38gpolosetfiles: + stringify.diff
keywords: + patch
messages: + msg89584
2009-04-22 23:39:38gpolosetstage: test needed
2009-04-22 23:29:31gpolosetversions: + Python 3.0, Python 3.1, Python 2.7
nosy: + gpolo

messages: + msg86345

assignee: gpolo
2009-01-16 09:38:24eb303create