0

I'm totally new to Python.

I just wrote this simple script that prints a message on my desktop:

from plyer import notification
notification.notify(
title="HI MATTEO!",
message="Here's the notification to be sent every hour!",
timeout=10
)

Here's the screenshot of the notification

I'd like to know if there's a way to run this notification every hour (or at a given time)

Thanks so much

Matteo Fossati

Roy2012
  • 11,755
  • 2
  • 22
  • 35
  • You should decide whether you want to have a Python program which runs continuously and performs certain actions at certain times, or if you want the operating system to run your program at certain times (and your program then performs the action and exits). If the latter, then you need to say which operating system you are using. For example, under Linux you would use `crontab`. – alani Jun 11 '20 at 06:16
  • I'd like to write a script inside the same program which makes the program itself run at certain times, so the first one – Matteo Fox Fossati Jun 11 '20 at 06:53
  • Unfortunately I don't 100% understand your reply, but if you want the first option, then it sounds like Roy2012's answer should give you what you want. – alani Jun 11 '20 at 07:01
  • Does this answer your question? [How do I get a Cron like scheduler in Python?](https://stackoverflow.com/questions/373335/how-do-i-get-a-cron-like-scheduler-in-python) – Joe Jun 11 '20 at 09:52
  • https://stackoverflow.com/questions/15088037/python-script-to-do-something-at-the-same-time-every-day – Joe Jun 11 '20 at 09:53

1 Answers1

1

You should look at the schedule package (https://pypi.org/project/schedule/).

Then, run something like:

schedule.every().hour.do(my_notification)
...
while True:
  schedule.run_pending()
  time.sleep(1)
Roy2012
  • 11,755
  • 2
  • 22
  • 35