#πŸ”’ How i can improve

22 messages Β· Page 1 of 1 (latest)

astral pecan
#

https://github.com/i-try-to-grind-everyday/Reminder-to-look-at-you

import time
import plyer




class Reminder:

    def __init__(self, title: str, message: str, app_icon: str, timeout: int):
        self.title = title
        self.message = message
        self.app_icon = app_icon
        self.timeout = timeout
        self.Running = False

    def start(self,intervel: int):
        self.Running = True
        while True:
            time.sleep(intervel)
            self.send_notification()


    def send_notification(self):
        plyer.notification.notify(
            title=self.title,
            message=self.message,
            app_icon=self.app_icon,
            timeout=self.timeout,
        )




drink_Reminder = Reminder(
    "Drink Water",
    "There is water in World",
    "/home/yousaytoday/Python/Reminder/Assets/red_alarm.ico",
    2,
)  # icon problem  - icon is not showing - any way working on logic



def main():
    # drink_Reminder.start(900)
    drink_Reminder.start(1) # just for testing


if __name__ == "__main__":
    main()

i am learning Classes
how i can improve it

GitHub

This Progarm send Health Related reminder notifications like "Take a break" , "Go for a walk" , "Drink Water" amd much other, - i-try-to-grind-...

deft briarBOT
#

Hey @astral pecan!

Please edit your message to use a code block

Add a py after the three backticks.

```py
print('Hello, world!')
```

This will result in the following:

print('Hello, world!')```
deft briarBOT
#

@astral pecan

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

vast cove
#

!pep8

deft briarBOT
#
PEP 8

PEP 8 is the official style guide for Python. It includes comprehensive guidelines for code formatting, variable naming, and making your code easy to read. Professional Python developers are usually required to follow the guidelines, and will often use code-linters like flake8 to verify that the code they're writing complies with the style guide.

More information:

vast cove
#

You could maybe also add in handling for KeyboardInterrupts so the program can be cleanly killed with ctrl+C.

astral pecan
vast cove
#

But surely you want to kill it eventually? If you're planning on always killing it by turning off your machine then that's not necessary I guess.

#

Oh, I see, you're going to run it back grounded so the user would need to foreground it to kill it.

astral pecan
vast cove
#

You could take a time value using command line arguments so you don't need to hardcode the 1.

vast cove
astral pecan
#

if i want run this script in linux background
i gonna try it
but it gonna give me error becuase plyar are not installed system level becuase it is installed in venv

vast cove
#

I'm about to step off the bus into -30C weather, so I may not be able to respond for a bit reliably.

vast cove
astral pecan
deft briarBOT
#
Python help channel closed for inactivity

This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.