简体   繁体   English

Python - tkinter.messagebox 在 macOS 中看不到标题和显示错误图标

[英]Python - tkinter.messagebox cannot see title and showerror icon in macOS

I use tkinter to do GUI.我使用 tkinter 来做 GUI。 When use messagebox, that can not see title and showerror icon is a file, just like that:使用messagebox时,看不到标题,showerror图标是一个文件,就像这样:

enter image description here在此处输入图像描述

This is my env:这是我的环境:

  1. macOS / windows 10 macOS / windows 10
  2. python 3.8.13 python 3.8.13
  3. tk 8.6传统知识 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.我想查看标题和错误图标,就像 windows 系统一样。 How can I do to fix this progrem, thanks.我该如何解决这个问题,谢谢。

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 ).或者mac设置(所以不是tkinter )。 How are the error messages currently displayed on the pc as one would expect tkinter to be consistent with this.当前如何在 PC 上显示错误消息,因为人们期望tkinter与此一致。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM