Search code examples
pythonmacostkintertkmessagebox

Why can't I change the icon on a tkMessagebox.askyesno() on OS X?


tkMessageBox.askyesno('Title', 'Message', icon=tkMessageBox.WARNING) on OS X just gives me the rocket icon.

I know there is some weirdness with OS X and tkMessageBox icons because tkMessageBox.showerror() just shows the rocket icon, but tkMessageBox.showwarning shows a yellow triangle (with a small rocket in the corner)

Is this is a bug?

Is there some workaround to get a warning triangle and Yes/No buttons without having to resort to making my own message box window from scratch?


Solution

  • I found a solution:

    tkMessageBox.askretrycancel(title, message, type=tkMessageBox.YESNO)
    

    seems to work, but both buttons presses return False, so it's not of any use.

    tkMessageBox.showwarning(title, message, type=tkMessageBox.YESNO)
    

    does also work work, but be aware that it returns 'yes' or 'no', not True or False. It's the only real option though.


    I would still be interested if anyone can tell me whether it is a bug.