我在 plyer.facades.Notification.notify() 中有一个错误,即类型错误:Notification.notify() 缺少 1 个必需的位置参数:'self'


# import Notification Method from plyer module
from plyer.facades import Notification 
# notify function declaration
def notifyMe(title,text):
Notification.notify(
title=title,
message=text,
app_icon=None,
timeout=5
)

# main function declaration
if __name__ == '__main__':
notifyMe("Notification","Just Click here to see what it is")

您正试图将实例方法作为类方法进行调用。您应该首先从Notification类创建一个对象,然后使用它来调用此方法。或者使用Singleton";"通知";由软件包开发人员为您提供。

也许这份文档会有所帮助:https://github.com/kivy/plyer/blob/master/plyer/facades/notification.py

# To send notification::
from plyer import notification
title = 'plyer'
message = 'This is an example.'
notification.notify(title=title, message=message)

最新更新