Wrappers#
Classes#
Possible colours for toast buttons |
|
Possible values for duration to display toast for |
|
Allowed positions for an image to be placed on a toast notification |
|
Possible scenarios for the toast |
|
|
Image that can be displayed in various toast elements |
Define an image that will be displayed as the icon of the toast |
|
Progress bar to be included in a toast |
|
A text box that can be added in toasts for the user to enter their input |
|
An item that the user can select from the drop down list |
|
A selection box control, which lets users pick from a dropdown list of options |
|
A button that the user can click on a toast notification |
|
Button used to perform a system action, snooze or dismiss |
|
Wrapper over Windows' ToastActivatedEventArgs to fix an issue with reading user input |
API#
- class windows_toasts.wrappers.ToastImage(imagePath: str | PathLike)[source]#
Image that can be displayed in various toast elements
- __init__(imagePath: str | PathLike)[source]#
Initialise an
ToastImage
class to use in certain classes. Online images are supported only in packaged apps that have the internet capability in their manifest. Unpackaged apps don’t support http images; you must download the image to your local app data, and reference it locally.- Parameters:
imagePath (Union[str, PathLike]) – The path to an image file
- Raises:
InvalidImageException: If the path to an online image is supplied
- path: str#
The URI of the image source
- enum windows_toasts.wrappers.ToastButtonColour(value)[source]#
Possible colours for toast buttons
Valid values are as follows:
- Default = <ToastButtonColour.Default: ''>#
- Green = <ToastButtonColour.Green: 'Success'>#
- Red = <ToastButtonColour.Red: 'Critical'>#
- enum windows_toasts.wrappers.ToastDuration(value)[source]#
Possible values for duration to display toast for
Valid values are as follows:
- Default: str = <ToastDuration.Default: 'Default'>#
- Short: str = <ToastDuration.Short: 'short'>#
- Long: str = <ToastDuration.Long: 'long'>#
- enum windows_toasts.wrappers.ToastImagePosition(value)[source]#
Allowed positions for an image to be placed on a toast notification
Valid values are as follows:
- Inline = <ToastImagePosition.Inline: ''>#
- Hero = <ToastImagePosition.Hero: 'hero'>#
- AppLogo = <ToastImagePosition.AppLogo: 'appLogoOverride'>#
- enum windows_toasts.wrappers.ToastScenario(value)[source]#
Possible scenarios for the toast
Valid values are as follows:
- Default: str = <ToastScenario.Default: ''>#
- Alarm: str = <ToastScenario.Alarm: 'alarm'>#
- Reminder: str = <ToastScenario.Reminder: 'reminder'>#
- IncomingCall: str = <ToastScenario.IncomingCall: 'incomingCall'>#
- Important: str = <ToastScenario.Important: 'urgent'>#
- enum windows_toasts.wrappers.ToastSystemButtonAction(value)[source]#
Valid values are as follows:
- Snooze = <ToastSystemButtonAction.Snooze: 0>#
- Dismiss = <ToastSystemButtonAction.Dismiss: 1>#
- class windows_toasts.wrappers.ToastDisplayImage(image: ToastImage, altText: str | None = None, position: ToastImagePosition = ToastImagePosition.Inline, circleCrop: bool = False)[source]#
Define an image that will be displayed as the icon of the toast
- image: ToastImage#
An image file
- altText: str | None = None#
A description of the image, for users of assistive technologies
- position: ToastImagePosition = ''#
Whether to set the image as ‘hero’ and at the top, or as the ‘logo’. Only works on
InteractableWindowsToaster
- circleCrop: bool = False#
If the image is not positioned as ‘hero’, whether to crop the image as a circle, or leave it as is
- classmethod fromPath(imagePath: str | PathLike, altText: str | None = None, position: ToastImagePosition = ToastImagePosition.Inline, circleCrop: bool = False) ToastDisplayImage [source]#
Create a
ToastDisplayImage
object from path without having to createToastImage
- class windows_toasts.wrappers.ToastProgressBar(status: str, caption: str | None = None, progress: float | None = 0, progress_override: str | None = None)[source]#
Progress bar to be included in a toast
- status: str#
Status string, which is displayed underneath the progress bar on the left. This string should reflect the status of the operation, like “Downloading…” or “Installing…”
An optional title string
- progress: float | None = 0#
The percentage value of the progress bar, {0..1}. Defaults to zero. If set to None, it will use an indeterminate bar
- progress_override: str | None = None#
Optional string to be displayed instead of the default percentage string
- class windows_toasts.wrappers.ToastInputTextBox(input_id: str, caption: str = '', placeholder: str = '')[source]#
A text box that can be added in toasts for the user to enter their input
- placeholder: str = ''#
Optional placeholder for a text input box
- class windows_toasts.wrappers.ToastSelection(selection_id: str, content: str)[source]#
An item that the user can select from the drop down list
- selection_id: str#
Identifier for the selection
- content: str#
Value for the selection to display
- class windows_toasts.wrappers.ToastInputSelectionBox(input_id: str, caption: str = '', selections: Sequence[ToastSelection] = (), default_selection: ToastSelection | None = None)[source]#
A selection box control, which lets users pick from a dropdown list of options
- selections: Sequence[ToastSelection] = ()#
Sequence of selections to include in the box
- default_selection: ToastSelection | None = None#
Selection to default to. If None, the default selection will be empty
- class windows_toasts.wrappers.ToastButton(content: str = '', arguments: str = '', image: ToastImage | None = None, relatedInput: ToastInputTextBox | ToastInputSelectionBox | None = None, inContextMenu: bool = False, tooltip: str | None = None, launch: str | None = None, colour: ToastButtonColour = ToastButtonColour.Default)[source]#
A button that the user can click on a toast notification
- content: str = ''#
The content displayed on the button
- arguments: str = ''#
String of arguments that the app will later receive if the user clicks this button
- image: ToastImage | None = None#
An image to be used as an icon for the button
An input to position the button besides
- inContextMenu: bool = False#
Whether to place the button in the context menu rather than the actual toast
- tooltip: str | None = None#
The tooltip for a button, if the button has an empty content string
- launch: str | None = None#
An optional protocol to launch when the button is pressed
- colour: ToastButtonColour = ''#
ToastButtonColour
for the button
- class windows_toasts.wrappers.ToastSystemButton(action: ToastSystemButtonAction, content: str = '', relatedInput: ToastInputSelectionBox | None = None, image: ToastImage | None = None, tooltip: str | None = None, colour: ToastButtonColour = ToastButtonColour.Default)[source]#
Button used to perform a system action, snooze or dismiss
- action: ToastSystemButtonAction#
Action the system button should perform
- content: str = ''#
A custom content string. If you don’t provide one, Windows will automatically use a localized string
If you want the user to select a snooze interval, set this to a ToastInputSelectionBox with the minutes as IDs
- image: ToastImage | None = None#
An image to be used as an icon for the button
- tooltip: str | None = None#
The tooltip for the button
- colour: ToastButtonColour = ''#
ToastButtonColour
to be displayed on the button
- class windows_toasts.events.ToastActivatedEventArgs(arguments: str | None = None, inputs: dict | None = None)[source]#
Wrapper over Windows’ ToastActivatedEventArgs to fix an issue with reading user input
- arguments: str | None = None#
Arguments provided to
AddAction()
- inputs: dict | None = None#
Inputs received when using
AddInput()
- classmethod fromWinRt(eventArgs: winrt.system.Object) ToastActivatedEventArgs [source]#