我尝试了这3个选项但它们不起作用。
Notify-send不是命令,我没有linux或ubuntu。
我无法在python中导入notify2,因为我得到错误,它说notify2库不能导入dbus,我试图pip3安装dbus,但它不存在(什么???)。我无法安装自制软件来修复它。
pqt5运行时没有编译错误,但没有显示任何通知。它在我的Mac上工作正常,但不在我的Windows PC上。
您可以使用tkinter,它是Tk GUI工具包的接口。
是Python 3:
import tkinter as tk
from tkinter import messagebox
root = tk.Tk()
root.withdraw() # This hides the main window of the gui
messagebox.showinfo("Pay attention", "Something happened!")
是Python 2:
import Tkinter as tk
import tkMessageBox
root = tk.Tk()
root.withdraw() # This hides the main window of the gui
tkMessageBox.showinfo("Pay attention", "Something happened!")
这会创建一个简单的弹出警报,并且应该在Windows上运行。