Toast¶
Classes¶
alias of |
|
|
Data¶
- windows_toasts.toast.ToastInput¶
alias of
ToastInputTextBox|ToastInputSelectionBox
API¶
- class windows_toasts.toast.Toast[source]¶
- __init__(text_fields: None | list[str | None] | tuple[str | None] | set[str | None] = None, audio: ToastAudio | None = None, duration: ToastDuration = ToastDuration.Default, expiration_time: datetime | None = None, group: str | None = None, launch_action: str | None = None, progress_bar: ToastProgressBar | None = None, attribution_text: str | None = None, scenario: ToastScenario = ToastScenario.Default, suppress_popup: bool = False, timestamp: datetime | None = None, on_activated: Callable[[ToastActivatedEventArgs], None] | None = None, on_dismissed: Callable[[winrt.windows.ui.notifications.ToastDismissedEventArgs], None] | None = None, on_failed: Callable[[winrt.windows.ui.notifications.ToastFailedEventArgs], None] | None = None, actions: Iterable[ToastButton | ToastSystemButton] = (), images: Iterable[ToastDisplayImage] = (), inputs: Iterable[ToastInputTextBox | ToastInputSelectionBox] = ()) None[source]¶
Initialise a toast
- Parameters:
actions (Iterable[Union[ToastButton, ToastSystemButton]]) – Iterable of actions to add; see
AddAction()images (Iterable[ToastDisplayImage]) – See
AddImage()inputs (Iterable[ToastInput]) – See
AddInput()
- audio: ToastAudio | None¶
The custom audio configuration for the toast
- duration: Literal[ToastDuration.Default, ToastDuration.Long, ToastDuration.Short]¶
ToastDuration, be it the default, short, or long
- scenario: ToastScenario¶
Scenario for the toast
- progress_bar: ToastProgressBar | None¶
An adjustable progress bar for the toast
- attribution_text: str | None¶
Text displayed below any text elements, but above inline images
- timestamp: datetime | None¶
A custom timestamp. If you don’t provide one, Windows uses the time that your notification was sent
- group: str | None¶
An internal identifier, where you can assign groups like “wallPosts”, “messages”, “friendRequests”, etc.
- expiration_time: datetime | None¶
The time for the toast to expire on in the action center. If it is on-screen, nothing will happen
- suppress_popup: bool¶
Whether to suppress the toast popup and relegate it immediately to the action center
- actions: list[ToastButton | ToastSystemButton]¶
List of buttons to include. Implemented through
AddAction()
- images: list[ToastDisplayImage]¶
See
AddImage()
- inputs: list[ToastInputTextBox | ToastInputSelectionBox]¶
Text/selection input boxes
- text_fields: list[str | None]¶
Various text fields
- on_activated: Callable[[ToastActivatedEventArgs], None] | None¶
Callable to execute when the toast is clicked if basic, or a button is clicked if interactable
- on_dismissed: Callable[[winrt.windows.ui.notifications.ToastDismissedEventArgs], None] | None¶
Callable to execute when the toast is dismissed (X is clicked or times out) if interactable
- on_failed: Callable[[winrt.windows.ui.notifications.ToastFailedEventArgs], None] | None¶
Callable to execute when the toast fails to display
- tag: str¶
Unique tag for the toast, automatically set as a UUID
- updates: int¶
Number of times the toast has been updated; mostly for internal use
- AddAction(action: ToastButton | ToastSystemButton) None[source]¶
Add an action to the action list. For example, if you’re setting up a reminder, you would use ‘action=remindlater&date=2020-01-20’ as arguments. Maximum of five.
- AddImage(image: ToastDisplayImage) None[source]¶
Adds an the image that will be displayed on the toast. If using WindowsToaster, a maximum of two (one as the logo and one hero) images will work.
- Parameters:
image –
ToastDisplayImageto display in the toast
- AddInput(toast_input: ToastInputTextBox | ToastInputSelectionBox) None[source]¶
Adds an input field to the notification. It will be supplied as user_input of type ValueSet in on_activated
- Parameters:
toast_input –
ToastInputto display in the toast
- property launch_action: str | None¶
Protocol to launch when the toast is clicked