python - Mac 上 Python 的消息窗口
问题描述
我正在使用 MAC OS,用于 python 程序。如果条件为真,我想显示一个消息框。True
有人可以告诉我如何为 macOS 创建一个 Python 消息框,当条件为or时可以调用它False
?
我试过了
import subprocess
applescript = """
display dialog "Some message goes here..." ¬
with title "This is a pop-up window" ¬
with icon caution ¬buttons {"OK"}"""
subprocess.call("osascript -e '{}'".format(applescript), shell=True)
但是这个,我不知道如何根据条件调用。
解决方案
可能这可以帮助
import Tkinter
import tkMessageBox
# An error box
if(condition)
tkMessageBox.showerror("Error","No disk space left on device")
# A warning box
if(condition)
tkMessageBox.showwarning("Warning","Could not start
service")
# An information box
if(condition)
tkMessageBox.showinfo("Information","Created in Python.")
推荐阅读
- c# - 我正在尝试使用 C#.NET 控制台应用程序在 SQL-Server 中的现有数据库中创建动态表。但我得到了例外
- jenkins - jenkinsfile 中的 SonarQube - 如果质量检查失败则停止
- javascript - 我不能再连接到mongodb了?
- javascript - Enmap (better-sqlite map) 在应用程序重新启动之前不会更新
- xml - 我的 XXE 有效负载没有得到关于我要利用的文件的响应
- reactjs - 开玩笑地模拟 useDispatch 并在功能组件中使用该调度操作来测试参数
- angular - 带有动态部分的角度路由
- kubernetes - 是否需要对有状态集使用无头服务?
- vb.net - 从数组对象 vb.net 播放 wav 文件时,波头损坏错误
- c# - 为什么这个字符串数组是空的?