0

I use tkinter to do GUI. When use messagebox, that can not see title and showerror icon is a file, just like that:

enter image description here

This is my env:

  1. macOS / windows 10
  2. python 3.8.13
  3. tk 8.6

And this is my code

import tkinter
from tkinter import messagebox

window = tkinter.Tk()
window.withdraw()
messagebox.showerror(title="error title", message="for test message")
window.destroy()

I want to see title and error icon, just like windows system. How can I do to fix this progrem, thanks.

Kenisnotme
  • 13
  • 4
  • not sure i understand the question. there is an error box.... – D.L Aug 14 '22 at 15:41
  • In windows, the error box has title and message, but macOS only show message on box. And windows has an error icon, macOS is a file icon. – Kenisnotme Aug 25 '22 at 01:03

2 Answers2

0
window = tkinter.Tk()
root.tk.call('wm', 'iconphoto', root._w, PhotoImage(file=your path))
messagebox.showerror(title="error title", message="for test message")
root.tk.call('wm', 'iconphoto', root._w, PhotoImage(file=your path))
toyota Supra
  • 3,181
  • 4
  • 15
  • 19
0

If there are features that are different for different operating systems, then you can determine the operating system like this:

import sys

p = sys.platform

if p == "linux" or p == "linux2":
    # linux
    print('using linux')
elif p == "darwin":
    # OS X
    print('using mac')
elif p == "win32":
    # Windows...
    print('using windows')

Alternatively the mac settings (so not tkinter). How are the error messages currently displayed on the pc as one would expect tkinter to be consistent with this.

D.L
  • 4,339
  • 5
  • 22
  • 45