'How to correct picture tkinter messagebox tkinter on macos
Is there a way to get pictures automatically on macos when you create a tkinter.messagebox ? I would like to get the error picture or question mark on my computer (I use macos and anaconda).
from tkinter import messagebox
messagebox.showinfo("Info", "Work in progress")
messagebox.showerror("Error", "Oups...")
Solution 1:[1]
Normally, the icons are corrected once the script is compiled into an app (tested with pyinstaller). However, on macOS this is not perfect and there is still issues with some icons (like the showerror icon)...
So I suggest you to manage the icons manually with the command:
root.tk.call('wm', 'iconphoto', root._w, PhotoImage(file="path/to/icon.png"))
This allows you to display a custom png image as icon, but this will also change the app icon. So I advise you to reinitialize the icon once the message is closed:
root.tk.call('wm', 'iconphoto', root._w, PhotoImage(file="path/to/icon.png"))
messagebox.showerror("Error", "Oups...")
root.tk.call('wm', 'iconphoto', root._w, PhotoImage(file="path/to/original_app_icon.png"))
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Marin Nagy |

