Open mre opened 4 years ago
I think we can start by creating a UI class, so that all notifications and other outputs go through it, and then it can handle them appropriately, and in the future use a different notify implementation.
For example, we might have methods called ui.error
, ui.info
, ui.debug
. Then we could replace, for example,
notify("Timelapse", f"Creating timelapse. This might take a while")
print(' '.join(command))
with
ui.info("Timelapse", f"Creating timelapse. This might take a while")
ui.debug(' '.join(command))
and then, for now, the ui.info
implementation can call notify
while the ui.debug
can call print
. In the future, we'll be able to update the implementations with better notifications and logging, etc.
I like your idea. If this was an external library, I'd expect a builder pattern like this:
notification = Notify.create()
.title("Title Text")
.text("Hello World!")
.icon('example.png');
notification.show()
This is similar to dorkbox/Notify.
The advantage would be, that we could customize our notification once and use the same style throughout the app.
notify()
would then become a wrapper around the builder, that we could maintain inside timelapse. The rest would probably be in a separate library to improve re-usability and avoid close coupling between the components - but this could be done in a next step. 😉
So if you want to work on this and refactor the code a bit, please be welcome to do so.
Feature Request Type
Description
At the moment, we use a custom function to show a notification (e.g. when a recording was started or stopped). Here is the code: https://github.com/mre/timelapse/blob/master/timelapse/notify.py This has some limitations:
It would be nice if we could use a library for showing proper notification instead. Not sure if there already exists a native Python library to do that on macOS. Does anybody know of such a library? If not, we could build one based on the discussion here.