➜

This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
标题: Inconsistent/wrong result of askyesno function in tkMessageBox
类型: behavior Stage: patch review
Components: Tkinter Versions: Python 3.0, Python 3.1, Python 2.7, Python 2.6
process
状态: closed Resolution: fixed
Dependencies: 后续:
分配给: 抄送列表: doko, eb303, gpolo, kvander11
优先级: normal 关键字: patch

Created on 2009-01-16 09:38 by eb303, last changed 2022-04-11 14:56 by admin. This issue is now closed.

文件
文件名 上传时间 Description 编辑
dialog-bug.py eb303, 2009-01-16 09:38
stringify.diff gpolo, 2009-06-21 21:41
Messages (7)
msg79944 - (view) Author: (eb303) 日期: 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) 日期: 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) 日期: 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) 日期: 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) 日期: 2010-03-16 10:14
the patch works for me with tcl8.5
msg101160 - (view) Author: Matthias Klose (doko) * (Python committer) 日期: 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) 日期: 2010-03-20 02:20
committed to the 2.6 branch as well
历史
日期 用户 动作 参数
2022-04-11 14:56:44admin修改github: 49211
2010-03-20 02:20:21doko修改状态: pending -> closed
assignee: gpolo ->
消息: + msg101356
2010-03-16 10:54:40doko修改状态: open -> pending
resolution: fixed
消息: + msg101160
2010-03-16 10:14:10doko修改抄送: + doko

消息: + msg101159
stage: test needed -> patch review
2010-01-11 22:20:25kvander11修改抄送: + kvander11
消息: + msg97610
2009-06-21 21:41:38gpolo修改文件: + stringify.diff
keywords: + patch
消息: + msg89584
2009-04-22 23:39:38gpolo修改stage: test needed
2009-04-22 23:29:31gpolo修改versions: + Python 3.0, Python 3.1, Python 2.7
抄送: + gpolo

消息: + msg86345

assignee: gpolo
2009-01-16 09:38:24eb303创建