windowstoast - Python Module for sending Toast Notifications on Windows 10
Installation
To install windowstoast from PyPi run:
pip install windowstoast
Usage
Create a Toast Notification
from windowstoast import Toast
t = Toast(AppID, NotificationID, ActivationType='protocol', Duration='short', Launch='file:', Scenario='default', Popup=True)
t.show()
#AppID = The application ID from the installed applications in windows. You can get that manually or use my another module 'windowsapps' for that.
#NotificationID = ID you can assign to the notification to identify it later.
#ActivationType = Type of activation for notification. 'system' or 'protocol'.
#Duration = Can be 'short' or 'long'.
#Launch = You can specify your file path to open on notification click, or add your own protocol action.
#Popup = Notification will not pop up if set to false.
Add Text to the Toast Notification
t.add_text(text, maxlines=None, attribution=None)
#text = Your text title(If there is only single text) or message(If there is already other text element present).
#maxlines = No. of lines to be occupied by the text.
#attribution = For attribute text at bottom of toast notification
Add Image to the Toast Notification
t.add_image(source, placement=None, hint-crop='circle')
#source = Source to the image file
#placement = If specified as 'logo' or 'appLogoOverride' them image will appear as a logo on the left of notification.
#hint-crop = Will make the image circular if specified as 'circle' or squared if specified 'square'.
Add Custom audio to the Toast Notification
t.add_audio(source="", silent=False)
#source = Source for the audio file.
#silent = Will make the notification appear silently if set True.
Add Progress Bar to the Toast Notification
t.add_progress(status, title, value, value_label)
#status = Text below the progress bar indicatiing its current state. Ex- 'Downloading...', 'Receiving...', etc.
#title = Title about the progress bar.
#value = A value between 0 and 1 for the progress.
#value_label = A text below the progress bar showing the current progress to the user. Ex- '26/100 Completed!', '54%', etc.
Add Context Menu to the Toast Notification
t.add_content_menu(content, arguments, activationType='protocol')
#content = Name for the context menu.
#argument = Specific argument for the menu.
#activationType = 'protocol' for a protocol activation in windows.
Add Button to the Toast Notification
t.add_button(content='Dismiss', argument='Dismiss', activationType='system')
#content = Name for the button.
#argument = Argument specified for the button.
#activationType = Can be specified as 'system' for just dissmisal of notification on button click or set as 'protocol' to launch your custom protocol.
#You can add maximum of 5 buttons.
Launch Custom Action on Button Click
# First create your own protocol in the windows registry by:
import windowstoast
create_protocol(protocol_uri, comman_target) # Run as Admin required for this!
#protocol_uri = Your own unique protocol uri name. Ex- 'My-Custom-Uri'
#command_target = Path to your own target application with arguments. Ex- r'"Absoulute\Path\To\My\Application.exe" "%1"'
# If you want to remove your protocol:
remove_protocol('Protocol_name') # Run as Admin required for this!
#Create your own Application.exe which takes the argument. Ex-
from sys import argv
a = argv[1:]
print(a)
# Here a is the value of argument that you will specify with the button in Notification.
#Now after making sure you have created your protocol and Application.exe, add button in the notification
t.add_button('My Button','My-Custom-Uri:My_Argument', 'protocol')
# Here you can specify your own protocol uri to execute an action or some other uri like - 'E:\Others\my_file.xyz' to open a file or 'https://www.google.com' to open website.
Update Your Notification
notificationID = '12345'
t = Toast('My Application ID', notificationID)
t.add_text('Title')
t.add_progress('Status...', 'Progress Title', '0', '0% Completed!')
t.show()
# To update the notification, simply create another notification with same notification id.
for i in range(10):
t = Toast('My Application ID', notificationID, Popup=False) # Set Popup to False whenever you update, otherwise notification will popup each time.
t.add_audio(silent=True) # Set silent to True whenever you update, otherwise audio will play each time.
t.add_text('Title')
t.add_progress('Status...', 'Progress Title', str(i/10), str(i)+'% Completed!')
t.show()
# It is recommended to update notification only after atleast 1.5 seconds.
Metadata
Release files for windowstoast 0.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| windowstoast-0.0.4.tar.gz | 6.6 kB | Without provenance | Details for windowstoast-0.0.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| windowstoast-0.0.4-py3-none-any.whl | Python 3 | none | any | Details for windowstoast-0.0.4-py3-none-any.whl |
Total release size: 13.4 kB
Release files / windowstoast-0.0.4.tar.gz
| Download URL | windowstoast-0.0.4.tar.gz |
|---|---|
| Size | 6.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0d4b638af12beb7cc3d7cdec20973b1e13fb602272f262fa83dd43aa91e47095
|
|
BLAKE2b-256 checksum How to use checksums |
39a78d042ae4b6cfd53b69c3901ecfc38eb1081aaf1df82e9ae9ad3f869d267c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.12.2
|
Release files / windowstoast-0.0.4-py3-none-any.whl
| Download URL | windowstoast-0.0.4-py3-none-any.whl |
|---|---|
| Size | 6.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
10e36148499c727fe253b716787a08c309e40402751b50fade53c0ca2af3d829
|
|
BLAKE2b-256 checksum How to use checksums |
a06f2b385865073552ea8f0df2a14b5b92c06421c0b587da4e426328a5d22cd8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.12.2
|
Security for windowstoast 0.0.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.