Skip to main content

Toast notifications for Windows 10 and 11

Project description

Python PyPI

win11toast

Toast notifications for Windows 10 and 11 based on WinRT

image

Installation

pip install win11toast

Usage

from win11toast import toast

toast('Hello Python🐍')

image

from win11toast import toast

toast('Hello Python', 'Click to open url', on_click='https://www.python.org')

Use callback

from win11toast import toast

toast('Hello Python', 'Click to open url', on_click=lambda args: print('clicked!', args))
# clicked! {'arguments': 'http:', 'user_input': {}}

Icon

from win11toast import toast

toast('Hello', 'Hello from Python', icon='https://unsplash.it/64?image=669')

image

Image

from win11toast import toast

toast('Hello', 'Hello from Python', image='https://4.bp.blogspot.com/-u-uyq3FEqeY/UkJLl773BHI/AAAAAAAAYPQ/7bY05EeF1oI/s800/cooking_toaster.png')

image

Progress

from time import sleep
from win11toast import notify, update_progress

notify(progress={
    'title': 'YouTube',
    'status': 'Downloading...',
    'value': '0',
    'valueStringOverride': '0/15 videos'
})

for i in range(1, 15+1):
    sleep(1)
    update_progress({'value': i/15, 'valueStringOverride': f'{i}/15 videos'})
update_progress({'status': 'Completed!'})

image

Attributes https://docs.microsoft.com/en-ca/uwp/schemas/tiles/toastschema/element-progress

Audio

from win11toast import toast

toast('Hello', 'Hello from Python', audio='ms-winsoundevent:Notification.Looping.Alarm')

Available audio https://docs.microsoft.com/en-us/uwp/schemas/tiles/toastschema/element-audio

Button

from win11toast import toast

toast('Hello', 'Hello from Python', button='Dismiss')
# {'arguments': 'dismiss', 'user_input': {}}

image

from win11toast import toast

toast('Hello', 'Click a button', buttons=['Approve', 'Dismiss', 'Other'])

image

Input

from win11toast import toast

toast('Hello', 'Type anything', input='reply', button='Send')
# {'arguments': 'dismiss', 'user_input': {'textbox': 'Hi there'}}

image

Selection

from win11toast import toast

toast('Hello', 'Which do you like?', selection=['Apple', 'Banana', 'Grape'], button='Submit')
# {'arguments': 'dismiss', 'user_input': {'selection': 'Grape'}}

image

image

No arguments

from win11toast import toast

toast()

image

Wrap text

from win11toast import toast

toast('Hello', 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Earum accusantium porro numquam aspernatur voluptates cum, odio in, animi nihil cupiditate molestias laborum. Consequatur exercitationem modi vitae. In voluptates quia obcaecati!')

image

Jupyter

from win11toast import toast_async

await toast_async('Hello Python', 'Click to open url', on_click='https://www.python.org')

image

Debug

from win11toast import toast

xml = """
<toast launch="action=openThread&amp;threadId=92187">

    <visual>
        <binding template="ToastGeneric">
            <text hint-maxLines="1">Jill Bender</text>
            <text>Check out where we camped last weekend! It was incredible, wish you could have come on the backpacking trip!</text>
            <image placement="appLogoOverride" hint-crop="circle" src="https://unsplash.it/64?image=1027"/>
            <image placement="hero" src="https://unsplash.it/360/180?image=1043"/>
        </binding>
    </visual>

    <actions>

        <input id="textBox" type="text" placeHolderContent="reply"/>

        <action
          content="Send"
          imageUri="Assets/Icons/send.png"
          hint-inputId="textBox"
          activationType="background"
          arguments="action=reply&amp;threadId=92187"/>

    </actions>

</toast>"""

toast(xml=xml)

image

Notifications Visualizer image

Acknowledgements

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

win11toast-0.15.tar.gz (6.4 kB view hashes)

Uploaded Source

Built Distribution

win11toast-0.15-py3-none-any.whl (6.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page