Skip to content

Inconsistent/wrong result of askyesno function in tkMessageBox #49211

Closed

Description

@eb303
mannequin
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']

    Activity

    1. eb303 commented on Jan 16, 2009

      eb303mannequin
      MannequinAuthor

      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.

    2. added
      type-bug
      on Jan 16, 2009
    3. gpolo commented on Apr 22, 2009

      gpolomannequin
      Mannequin

      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.

    4. self-assigned this
      on Apr 22, 2009
    5. gpolo commented on Jun 21, 2009

      gpolomannequin
      Mannequin

      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.

    6. kvander11 commented on Jan 11, 2010

      kvander11mannequin
      Mannequin

      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
    7. doko42 commented on Mar 16, 2010

      @doko42
      Member

      the patch works for me with tcl8.5

    8. doko42 commented on Mar 16, 2010

      @doko42
      Member

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

    9. doko42 commented on Mar 20, 2010

      @doko42
      Member

      committed to the 2.6 branch as well

    10. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      topic-tkintertype-bug

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions