1

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...")

I get the window below with a not meaning full picture. mesaage box picture

Laurent R
  • 783
  • 1
  • 6
  • 25

1 Answers1

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"))

Marin Nagy
  • 297
  • 1
  • 10