I am new to python programming and was trying to make this program work which is supposed to work as a drink water windows notification reminder.
# importing python’s standard time utility module
import time
from plyer import notification
if __name__ == '__main__':
while True:
notification.notify(
title = "**Please Drink Water Now!!",
message ="The National Academies of Sciences, Engineering, and Medicine determined that an adequate daily fluid intake is: About 15.5 cups (3.7 liters) of fluids for men. About 11.5 cups (2.7 liters) of fluids a day for women.",
app_icon = "C:/Users/swast/OneDrive/Desktop/pythProject/media/icon.png",
timeout= 12
)
time.sleep(6)
Whenever I try to run this program, my computer slows down for some reason and the output tab beside the terminal keeps on going while there is no notification, what am I doing wrong here?
Here is the hotfix to your code as suggested:
# importing python’s standard time utility module
import time
from plyer import notification
if __name__ == '__main__':
while True:
notification.notify(
title = "**Please Drink Water Now!!",
message ="The National Academies of Sciences, Engineering, and Medicine determined that an adequate daily fluid intake is: About 15.5 cups (3.7 liters) of fluids for men. About 11.5 cups (2.7 liters) of fluids a day for women.",
app_icon = "C:/Users/swast/OneDrive/Desktop/pythProject/media/icon.png",
timeout= 12
)
time.sleep(6)
A proper way to do this would be to use a crontab to call the script at desired times. The script would call notification.notify
only once.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.