Notifications are imported in a different manner:
from aquaui.notification.native_notification import Notification
To use notifications, the following dependencies are required:
pyobjc-core
pyobjc-framework-NotificationCenter
pyobjc-framework-UserNotifications
pyobjc-framework-UserNotificationsUI
If you are unable to or cannot install them, use ApplescriptNotification
instead:
from aquaui import ApplescriptNotification
A native notification with a customizable title, subtitle, and informational text. In some cases, and icon and delay can also be set.*
text
: The notification's body text
Similarly, these are also all chainable functions
The notification's title, the first line.
Note that the notification's title does not change the notification's app name. The notification's app name defaults to "Python", and the only way to change it is by packaging your app with py2app
and setting the icon.
Set the subtitle of the notification (second line).
Set the informational text of the notification (third line).
Set the image on the right side of the notification. This does not change the "app image", which defaults to the Python Rocket. This Rocket image can only change if you package your app with py2app
and set a custom icon.
Set the delay in seconds between when .send()
is called and the notification being shown.
Send the notification.
* Please see this stackoverflow answer. If your mac is unable to send notification from Python for an reason, aquaui will fallback to AppleScript notifications, where only the title and subtitle can be specified. The icon will be that of the AppleScript editor app.
from aquaui import Notification
notification = (
Notification("Hello!")
.with_subtitle("This is the subtitle!")
.with_informative_text("Isn't this informative?")
.with_identity_image("assets/folder.png") # the image on the right of the notification
.send()
)
from aquaui import Notification
notification = Notification("Your pizza is here!").with_delay(15).send()
# 15 seconds delay
In some cases, the native notification cannot be displayed, so the fallback notification will be sent instead. This fallback notification can only have the title, subtitle, and informational text. It cannot have an icon or delay.
- TBD