python - Python非阻塞通知/消息
问题描述
我有非常基本的简单要求,每次运行程序时,我都必须在运行 python 程序(3.X)时在 Windows 10 上显示非阻塞消息信息,但这需要两个主要条件
它应该是非阻塞的,这意味着我的 python 程序不会等待用户操作关闭或用户的任何其他操作
其次,程序执行时消息不应该消失。
我试过 tkinter、win10Toas、Plyer ...等。但未能成功实现这个简单的结果。
我在 tkinter 中的代码如下
import tkinter as tk
def show_message(type1, msg1, msg2, msg3):
root = tk.Tk()
if type1 == "L":
h1 = "LOSS Notifications"
tk.Label(root, text=msg1, fg="red", bg="yellow", font="Verdana 14 bold").pack()
tk.Label(root, text=msg2, fg="red", bg="yellow", font="Verdana 14 bold").pack()
tk.Label(root, text=msg3, fg="black", bg="orange", font="Verdana 14 bold").pack()
elif type1 == "P":
h1 = "Profit Notifications"
tk.Label(root, text=msg1, fg="yellow", bg="blue", font="Verdana 14 bold").pack()
tk.Label(root, text=msg2, fg="yellow", bg="blue", font="Verdana 14 bold").pack()
tk.Label(root, text=msg3, fg="white", bg="green", font="Verdana 14 bold").pack()
elif type1 == "N":
h1 = "No Loss No Profit Notifications"
tk.Label(root, text=msg1, fg="black", bg="white", font="Verdana 14 bold").pack()
tk.Label(root, text=msg2, fg="black", bg="white", font="Verdana 14 bold").pack()
tk.Label(root, text=msg3, fg="black", bg="white", font="Verdana 14 bold").pack()
root.title(h1)
root.bell()
tk.mainloop()
此代码正在等待用户操作,没有此程序不会成功完成
你能帮忙吗?
解决方案
推荐阅读
- angular - Angular 作为 Express 子应用
- python - 在检查用户输入时,需要 Python 删除外部文件中逗号后的所有内容
- powershell - 从应用服务计划中删除 appinsights 分析器
- sonarqube - 蟒蛇 | SonarQube Scanner 执行期间出错 | 第 3832 行超出文件 .py 的范围
- javascript - 尝试使用包含媒体实体的 Twitter API 创建水平布局?
- javascript - 如何使用 jquery 替换 html 中的文本?
- bash - AppleScript 将错误号转发到 osascript 作为退出状态
- java - 如何在 Spring Boot 框架中发送 HTTP 请求?
- python - 无法在 vertica_sdk 中使用 TransformFunction
- python - 为什么我没有尝试使用 requests.post 发布帖子?