Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent/wrong result of askyesno function in tkMessageBox #49211

Closed
eb303 mannequin opened this issue Jan 16, 2009 · 7 comments
Closed

Inconsistent/wrong result of askyesno function in tkMessageBox #49211

eb303 mannequin opened this issue Jan 16, 2009 · 7 comments
Labels
topic-tkinter type-bug An unexpected behavior, bug, or error

Comments

@eb303
Copy link
Mannequin

eb303 mannequin commented Jan 16, 2009

BPO 4961
Nosy @doko42
Files
  • dialog-bug.py
  • stringify.diff
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2010-03-20.02:20:21.782>
    created_at = <Date 2009-01-16.09:38:24.424>
    labels = ['type-bug', 'expert-tkinter']
    title = 'Inconsistent/wrong result of askyesno function in tkMessageBox'
    updated_at = <Date 2010-03-20.02:20:21.780>
    user = 'https://bugs.python.org/eb303'

    bugs.python.org fields:

    activity = <Date 2010-03-20.02:20:21.780>
    actor = 'doko'
    assignee = 'none'
    closed = True
    closed_date = <Date 2010-03-20.02:20:21.782>
    closer = 'doko'
    components = ['Tkinter']
    creation = <Date 2009-01-16.09:38:24.424>
    creator = 'eb303'
    dependencies = []
    files = ['12761', '14333']
    hgrepos = []
    issue_num = 4961
    keywords = ['patch']
    message_count = 7.0
    messages = ['79944', '86345', '89584', '97610', '101159', '101160', '101356']
    nosy_count = 4.0
    nosy_names = ['doko', 'gpolo', 'eb303', 'kvander11']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'patch review'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue4961'
    versions = ['Python 2.6', 'Python 3.0', 'Python 3.1', 'Python 2.7']

    @eb303
    Copy link
    Mannequin Author

    eb303 mannequin commented Jan 16, 2009

    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.

    @eb303 eb303 mannequin added topic-tkinter type-bug An unexpected behavior, bug, or error labels Jan 16, 2009
    @gpolo
    Copy link
    Mannequin

    gpolo mannequin commented Apr 22, 2009

    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.

    @gpolo gpolo mannequin self-assigned this Apr 22, 2009
    @gpolo
    Copy link
    Mannequin

    gpolo mannequin commented Jun 21, 2009

    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.

    @kvander11
    Copy link
    Mannequin

    kvander11 mannequin commented Jan 11, 2010

    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

    @doko42
    Copy link
    Member

    doko42 commented Mar 16, 2010

    the patch works for me with tcl8.5

    @doko42
    Copy link
    Member

    doko42 commented Mar 16, 2010

    fixed for 2.7, 3.1, 3.2, commit pending for 2.6 until after the 2.6.5 release

    @doko42
    Copy link
    Member

    doko42 commented Mar 20, 2010

    committed to the 2.6 branch as well

    @doko42 doko42 closed this as completed Mar 20, 2010
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    topic-tkinter type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant