Python Forum
Chronometer/notifiactions/countdown program using notify2
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Chronometer/notifiactions/countdown program using notify2
#1
Hello!

I just finished writing a program on a Debian amd64 laptop for Python3 and it seems fine.
Basically it is a program that notifies you when you use your computer and you have to do something else.
In the program, there is also a chronometer (just for fun, you problably won't use it Tongue ) and a countdown chronometer which you probably won't use either but I added it anyway.

Remember that if you want to close the notification (it keeps popping up) you need to kill the program (I have instructions when running it).

Also, you will need notify2, a library only for linux (I think).
Any suggestions and/or modifications will be welcome Smile .
I would like seeing someone translate this program to work on Windows since I don't really use them to code, so I don't really know the libraries there.

You can download the program from my website
Or you can directly get the source code:

import time
import notify2
import datetime
#this program is built for linux with notify2 installed

def start():
    print("Hello and welcome to SmartReminder")
    basicin = input ("What do you want to do? (press '?' for help):  ")
    if basicin == "?":
        print("You can press 'notification' to set a notification.")
        print("You can press 'timer' to set a timer")
        basicin = input ("You can press 'countdown' to set a countdown:  ")
    if basicin == "notification":
        notification()
    if basicin == "timer":
        timer()
    if basicin == "countdown":
        countdown()
    else:
        print("Something went wrong with the command you entered")
        
def notification():
    notification = input("Set the time for the notification (e.g. 19:30):  ")
    name = input("Set the name for the notification:  ")
    body = input("Set the body text of the notification:  ")
    print("To stop the notification, close the program pressing Ctrl + C in the Python Idle")
    
    notify2.init('notification') 
    n = notify2.Notification(name,
                         body,
                         "notification-message-im"
                        )
    while True:
        if datetime.datetime.now().strftime("%H:%M") == notification:
            n.show()
def timer():
    timeelapsed = 0
    print("Close the program using Ctrl + C to stop the timer")
    timer = input("Write 'start' to start the timer (seconds):  ")
    if timer == "start":
        while True:
            time.sleep(1)
            timeelapsed = timeelapsed + 1
            print (timeelapsed)
    
def countdown():
    notify2.init('notification') 
    n = notify2.Notification("Countdown Over","The countdown you set in SmartReminder ended",
                         "notification-message-im")
    countdown = int(input("Set the time for the countdown (seconds):  "))
    while countdown > 0:
        print (countdown)
        time.sleep(1)
        countdown = countdown - 1
    n.show()


while True:       
    start()
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Radio speakers countdown timer Alkatron 0 2,510 Mar-16-2018, 10:36 AM
Last Post: Alkatron

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020