首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >问答首页 >Python ->提醒未弹出

Python ->提醒未弹出
EN

Stack Overflow用户
提问于 2020-11-30 15:26:00
回答 1查看 179关注 0票数 0

我正在做一个关于通知程序的项目,该程序在您编辑excel文件时读取该文件,然后在您设置提醒的时间发送通知。代码如下:

代码语言:javascript
代码运行次数:0
运行
复制
import pandas as pd
import datetime
from plyer import notification


def remind(title, message):
    notification.notify(title=title, message=message, timeout=10)


if __name__ == '__main__':
    while True:
        df = pd.read_excel("./reminder.xlsx")
        for index, item in df.iterrows():
            time = datetime.datetime.now().strftime("%H:%M:%S")
            if time == item['Time']:
                remind(item['Title'], item['Message'])
            else:
                continue

程序运行正常,但没有弹出提示我正在win8 (64位)上使用Python3.7.9

EN

回答 1

Stack Overflow用户

发布于 2021-06-17 18:54:35

代码语言:javascript
代码运行次数:0
运行
复制
from numpy import nan
import pandas as pd
import datetime
from plyer import notification
import time


def notifyMe(title, message,icon):
    notification.notify(
        title=title, 
        message=message, 
        app_icon = icon,
        timeout=10)


if __name__ == '__main__':
    
    notifyMe("Hello","We are in together in these tough time","virusicon.ico")

    df = pd.read_excel("reminder.xlsx")
    df["Icon"] = df["Icon"].astype(str)  
    df["Heading"] = df["Heading"].astype(str)
    df["Message"] = df["Message"].astype(str)

    number_of_rows = len(df.index)

    while True:
        flag = True
        for item in range(0,number_of_rows):
            now = datetime.datetime.strptime(datetime.datetime.now().strftime("%H:%M:%S"),"%H:%M:%S")
            x = datetime.datetime.strptime(df['Time'][item].strftime("%H:%M:%S"),"%H:%M:%S")
            if x==now:
                print(True)
                print(df['Heading'][item], df['Message'][item],df["Icon"][item])
                if df["Icon"][item]=="nan":
                    df["Icon"][item]=""
                if df["Message"][item]=="nan":
                    df["Message"][item]=""
                if df["Heading"][item]=="nan":
                    df["Heading"][item]=""
                notifyMe(df['Heading'][item], df['Message'][item],df['Icon'][item])
                time.sleep(1)
            if  now<=x:
                flag = False
        if flag:
            exit()

Format of the xslx file

你可以试试这个。它可能会对你有帮助

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65069496

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档