【问题标题】:Toast Notifier is not working, Have i done something wrong?Toast Notifier 不工作,我做错了吗?
【发布时间】:2021-05-04 21:53:38
【问题描述】:

首先感谢您花时间阅读本文:

我目前正在尝试让 ToastNotifier 在 MU 的 python 中工作。 我已经从 win10toast 导入了 ToastNotifier :

from win10toast import ToastNotifier

我已经创建了这个函数:

def notifacation():
    toast = ToastNotifier()
    Title = "Notifacation"
    message = "Hello from Ben Colledge"
    icon = "a.ico"
    length = 30
    toast.show_toast(title, message, icon_path=icon, duration=length)

然后像这样调用函数:

notifacation()

然后我运行代码,它给了我这个错误消息

回溯(最近一次通话最后一次):
文件“c:\users\puzzl\mu_code\notifacation.py”,第 1 行,在模块中
从 win10toast 导入 ToastNotifier
ModuleNotFoundError: 没有名为“win10toast”的模块

然后我去了https://pypi.org/project/win10toast/并下载了win10toast但什么也没发生

任何帮助将不胜感激 谢谢

【问题讨论】:

  • 尝试通过命令提示符pip install win10toast安装它
  • 感谢回复,
  • 我试过了,它说以下'pip'不是内部或外部命令、可运行程序或批处理文件。

标签: python pip toast


【解决方案1】:

我有完全相同的问题,但后来我想通了,这个效果最好 P>

python.exe -m pip install win10toast

我跑此代码,它仍然有一个问题没有,虽然,相同的一个。现在错误将是在具有该方法的行。 P>

toast.show_toast(title, message, icon_path=icon, duration=length)

的问题是,“标题”是未定义。你赋值的变量被命名为“标题”。由于Python是大小写敏感的,“标题”是undifined变量。这是该行应现在是什么样子: P>

toast.show_toast(Title, message, icon_path=icon, duration=length)

耶!它的工作原理吧! P>

【讨论】:

  • 事实上,我使用此方法来安装win10toast自己跨度>
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-04-17
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多