Skip to content

0.2.0

Latest
Compare
Choose a tag to compare
@ysfchn ysfchn released this 21 Mar 15:15
462e2d1

Frame 248

After a whole year, Toasted became more polished day after day, so unfortunately this resulted in many breaking changes but in the end, it also resulted with a bunch of cool features. Not every change is listed here, since some of them are internal changes that are not supposed to be used by developers.

Features

  • Create images from Windows icon font (Segoe Fluent or Segoe MDL2), which then can be used as an icon in toast elements.
    • A custom URI has also been added for convenience, for example if you set icon://E706 as a source in image element, it will show a sun/brightness icon.
  • Specify a custom sound for toast that will be played when toast is shown. Both HTTP links and file paths are supported.
    • To set a custom sound, use sound attribute. When a custom sound has provided, notification's own sound will be muted and "winsound" module (from stdlib) will be used to play sounds. You can also use mute_sound parameter in show() method to silent the toast for once, which can be useful if you plan to send one-after-one toasts.
  • Instead of notifications appearing with the name "Python", make them appear with a special name and icon by adding the required keys with Toast.register_app_id() method to the Windows registry. To remove the registered app ID, use Toast.unregister_app_id(). Windows doesn't require a reboot for toast app registrations, however, you need to make sure that all notifications sent by this library are cleared from Action Center to make Windows to clear the icon/name cache.

Enhancements

  • Toast.update() now returns a boolean and accepts missing_ok parameter to not raise an exception if notification was not found.
  • Toast.show() now returns a ToastResult, so setting a callback is not the only option anymore. Setting a callback is still and will be supported, and show() method will return a ToastResult regardless of if you set a callback or not.
  • Added Toast.is_registered_app_id, Toast.can_send_from_app_id, Toast.uses_custom_sound,Toast.uses_windows_sound, Toast.get_theme_info.
  • Added support for data: URIs as a source to images.
  • Updated examples. They are now created with fully Python, instead of loading a toast elements JSON.

🚩 Breaking changes

  • Group and Subgroup elements are removed, simply use lists of lists instead when defining elements. Old JSON payloads won't work.
  • Elements are now stored in Toast.elements, rather than Toast.data.
  • Toast.to_xml is superseded by Toast.to_xml_string.
  • Toast.remote_images has renamed to Toast.remote_media. The JSON key has also renamed to "remote_media".
  • Fixed typo in Button.is_content to Button.is_context.
  • ms-appdata URIs now resolve to the %APPDATA%.
  • If base path is None, current directory will be used instead for relative local file paths.
  • Handlers now only gets ToastResult object that wraps all related information.
  • Removed history_* methods, instead use toast.history (instance, bound to toast) or History (class, for any toast).
  • Renamed source_app_id to app_id. It is also now shared in all Toast instances. As app IDs are meant for per process, it was meaningless to keep different values for each Toast instance.
  • Toast.show() parameter signature has changed (positional).
  • Removed Toast.use_button_style. It is now determined automatically if toast has a button with style.
  • For JSON import, component types are now defined with _type key instead of @type key.
Internal changes
  • ToastMediaFileSystem is now used for downloading media files to the temporary directory, thus external fs dependency has removed.
  • Better URI handler, now it can resolve paths more properly.
  • It appears to be, notification groups are not a thing in Windows 11, so group_id won't be set for notifications (even if provided one) if running in Windows 11.
  • ToastSound is no longer an Enum.
  • Added FEATURE_NOT_AVAILABLE value to ToastNotificationMode for cases when notification mode can't be determined on specific versions of Windows.
  • Toast._toast_handler is now Toast._callback_result.
  • Toast._show_handler is now Toast._callback_show.
  • Toast._manager is now Toast._imp_manager.
  • Toast._toast is now Toast._imp_toast.
  • ToastElement.to_xml is superseded by ToastElement.to_xml_data, and returns a XMLData object instead.
  • New internal methods for Toast.