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

醉酒当歌 提交于 2020-08-07 17:58:08

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/39756822/why-cant-i-change-the-icon-on-a-tkmessagebox-askyesno-on-os-x

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!