windows10定时调起系统通知,每一个小时提醒该喝水了,精选Python面试真题集锦

本文介绍如何使用Python的win10toast库创建一个定时器,每小时提醒用户喝水。通过示例代码展示了如何初始化通知调用对象、设置通知参数以及使用定时器触发系统通知。此外,还分享了Python学习资源,包括学习路线、开发工具、全套学习视频、实战案例和大厂面试真题。
摘要由CSDN通过智能技术生成

from win10toast import ToastNotifier # 导入系统通知对象

import time # 系统时间模块

import datetime

from threading import Timer # 定时器

初始化通知调用对象

notify = ToastNotifier() # 初始化系统通知对象

初始化windows通知相关的参数,设置定时通知间隔时间等。

notify_head = ‘主人,来通知啦!’

notify_min = 1.0

notify_text = ‘已经过了’ + str(int(notify_min)) + ‘分钟了,该喝水了!’

notify_sen = notify_min * 1

通知调起时,是使用win10toast的show_toast()函数,参数和定义如下面。

‘’’

def show_toast(self, title=“Notification”, msg=“Here comes the message”,

icon_path=None, duration=5, threaded=False):

“”"Notification settings.

:title: notification title

:msg: notification message

:icon_path: path to the .ico file to custom notification

:duration: delay in seconds before notification self-destruction

“”"

‘’’

show_toast()函数

  • 15
    点赞
  • 20
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值