第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

windows10定時(shí)調(diào)起系統(tǒng)通知,每一個(gè)小時(shí)提醒該喝水了...

標(biāo)簽:
Python

win10toast是一个windows通知的出发框架,使用它可以轻松的调起系统通知。通过它可以很方便的做一个定时通知的功能应用。

file

安装调起通知的依赖库

pip install win10toast

导入相关的第三方依赖库

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()函数的使用,采用timer定时器来定时的调起应用发送通知。

def show_toast():
    print('当前时间:%s' % (datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')))
    notify.show_toast(f"{notify_head}", f"{notify_text}", duration=5, threaded=True, icon_path='水杯.ico')
    while notify.notification_active():
        time.sleep(0.005)
    timer = Timer(notify_sen, show_toast)
    timer.start()

主函数入口调用。

if __name__ == '__main__':
    show_toast()
點(diǎn)擊查看更多內(nèi)容
TA 點(diǎn)贊

若覺(jué)得本文不錯(cuò),就分享一下吧!

評(píng)論

作者其他優(yōu)質(zhì)文章

正在加載中
  • 推薦
  • 評(píng)論
  • 收藏
  • 共同學(xué)習(xí),寫下你的評(píng)論
感謝您的支持,我會(huì)繼續(xù)努力的~
掃碼打賞,你說(shuō)多少就多少
贊賞金額會(huì)直接到老師賬戶
支付方式
打開微信掃一掃,即可進(jìn)行掃碼打賞哦
今天注冊(cè)有機(jī)會(huì)得

100積分直接送

付費(fèi)專欄免費(fèi)學(xué)

大額優(yōu)惠券免費(fèi)領(lǐng)

立即參與 放棄機(jī)會(huì)
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)

舉報(bào)

0/150
提交
取消