{"id":16606317,"url":"https://github.com/niklashenning/pyqttoast","last_synced_at":"2025-04-07T07:00:23.547Z","repository":{"id":224533264,"uuid":"763509484","full_name":"niklashenning/pyqttoast","owner":"niklashenning","description":"A fully customizable toast notification library for PyQt and PySide","archived":false,"fork":false,"pushed_at":"2025-03-26T23:58:15.000Z","size":154,"stargazers_count":109,"open_issues_count":5,"forks_count":10,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-06T05:40:18.515Z","etag":null,"topics":["notification","pypi-package","pyqt","pyqt5","pyqt6","pyqttoast","pyside","pyside2","pyside6","python","toast","toast-notifications"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/pyqt-toast-notification/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/niklashenning.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-02-26T12:37:58.000Z","updated_at":"2025-03-27T05:42:39.000Z","dependencies_parsed_at":"2024-04-08T16:36:17.609Z","dependency_job_id":"d8af561e-10eb-4a06-a63e-c6d6e8a1350c","html_url":"https://github.com/niklashenning/pyqttoast","commit_stats":null,"previous_names":["niklashenning/pyqt-toast-notification","niklashenning/pyqt-toast","niklashenning/pyqttoast"],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/niklashenning%2Fpyqttoast","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/niklashenning%2Fpyqttoast/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/niklashenning%2Fpyqttoast/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/niklashenning%2Fpyqttoast/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/niklashenning","download_url":"https://codeload.github.com/niklashenning/pyqttoast/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247441007,"owners_count":20939233,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["notification","pypi-package","pyqt","pyqt5","pyqt6","pyqttoast","pyside","pyside2","pyside6","python","toast","toast-notifications"],"created_at":"2024-10-12T01:07:37.422Z","updated_at":"2025-04-07T07:00:23.459Z","avatar_url":"https://github.com/niklashenning.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PyQt Toast\n\n[![PyPI](https://img.shields.io/badge/pypi-v1.3.3-blue)](https://pypi.org/project/pyqt-toast-notification/)\n[![Python](https://img.shields.io/badge/python-3.7+-blue)](https://github.com/niklashenning/pyqttoast)\n[![Build](https://img.shields.io/badge/build-passing-neon)](https://github.com/niklashenning/pyqttoast)\n[![Coverage](https://img.shields.io/badge/coverage-94%25-green)](https://github.com/niklashenning/pyqttoast)\n[![License](https://img.shields.io/badge/license-MIT-green)](https://github.com/niklashenning/pyqttoast/blob/master/LICENSE)\n\nA fully customizable and modern toast notification library for PyQt and PySide\n\n![pyqttoast](https://github.com/niklashenning/pyqt-toast/assets/58544929/c104f10e-08df-4665-98d8-3785822a20dc)\n\n## Features\n* Supports showing multiple toasts at the same time\n* Supports queueing of toasts\n* Supports 7 different positions\n* Supports multiple screens\n* Supports positioning relative to widgets\n* Modern and fully customizable UI\n* Works with `PyQt5`, `PyQt6`, `PySide2`, and `PySide6`\n\n## Installation\n```\npip install pyqt-toast-notification\n```\n\n## Usage\nImport the `Toast` class, instantiate it, and show the toast notification with the `show()` method:\n\n```python\nfrom PyQt6.QtWidgets import QMainWindow, QPushButton\nfrom pyqttoast import Toast, ToastPreset\n\n\nclass Window(QMainWindow):\n    def __init__(self):\n        super().__init__(parent=None)\n\n        # Add button and connect click event\n        self.button = QPushButton(self)\n        self.button.setText('Show toast')\n        self.button.clicked.connect(self.show_toast)\n    \n    # Shows a toast notification every time the button is clicked\n    def show_toast(self):\n        toast = Toast(self)\n        toast.setDuration(5000)  # Hide after 5 seconds\n        toast.setTitle('Success! Confirmation email sent.')\n        toast.setText('Check your email to complete signup.')\n        toast.applyPreset(ToastPreset.SUCCESS)  # Apply style preset\n        toast.show()\n```\n\n\u003e **IMPORTANT:** \u003cbr\u003eAn instance of `Toast` can only be shown **once**. If you want to show another one, even if the content is exactly the same, you have to create another instance.\n\n\n## Customization\n\n* **Setting the position of the toasts (\u003cu\u003estatic\u003c/u\u003e):**\n```python\nToast.setPosition(ToastPosition.BOTTOM_MIDDLE)  # Default: ToastPosition.BOTTOM_RIGHT\n```\n\u003e **AVAILABLE POSITIONS:** \u003cbr\u003e `BOTTOM_LEFT`, `BOTTOM_MIDDLE`, `BOTTOM_RIGHT`, `TOP_LEFT`, `TOP_MIDDLE`, `TOP_RIGHT`, `CENTER`\n\n\n* **Setting whether the toasts should always be shown on the main screen (\u003cu\u003estatic\u003c/u\u003e):**\n```python\nToast.setAlwaysOnMainScreen(True)  # Default: False\n```\n\n* **Positioning the toasts relative to a widget instead of a screen (\u003cu\u003estatic\u003c/u\u003e):**\n```python\nToast.setPositionRelativeToWidget(some_widget)  # Default: None\n```\n\n* **Setting a limit on how many toasts can be shown at the same time (\u003cu\u003estatic\u003c/u\u003e):**\n```python\nToast.setMaximumOnScreen(5)  # Default: 3\n```\n\u003e If you try to show more toasts than the maximum amount on screen, they will get added to a queue and get shown as soon as one of the currently showing toasts is closed.\n\n\n* **Setting the vertical spacing between the toasts (\u003cu\u003estatic\u003c/u\u003e):**\n```python\nToast.setSpacing(20)  # Default: 10\n```\n\n* **Setting the x and y offset of the toast position (\u003cu\u003estatic\u003c/u\u003e):**\n```python\nToast.setOffset(30, 55)  # Default: 20, 45\n```\n\n* **Making the toast show forever until it is closed:**\n```python\ntoast.setDuration(0)  # Default: 5000\n```\n\n* **Enabling or disabling the duration bar:**\n```python\ntoast.setShowDurationBar(False)  # Default: True\n```\n\n* **Adding an icon:**\n```python\ntoast.setIcon(ToastIcon.SUCCESS)  # Default: ToastIcon.INFORMATION\ntoast.setShowIcon(True)           # Default: False\n\n# Or setting a custom icon:\ntoast.setIcon(QPixmap('path/to/your/icon.png'))\n\n# If you want to show the icon without recoloring it, set the icon color to None:\ntoast.setIconColor(None)  # Default: #5C5C5C\n```\n\u003e **AVAILABLE ICONS:** \u003cbr\u003e `SUCCESS`, `WARNING`, `ERROR`, `INFORMATION`, `CLOSE`\n\n\n* **Setting the icon size:**\n```python\ntoast.setIconSize(QSize(14, 14))  # Default: QSize(18, 18)\n```\n\n* **Enabling or disabling the icon separator:**\n```python\ntoast.setShowIconSeparator(False)  # Default: True\n```\n\n* **Setting the close button alignment:**\n```python\ntoast.setCloseButtonAlignment(ToastButtonAlignment.MIDDLE)  # Default: ToastButtonAlignment.TOP\n```\n\u003e **AVAILABLE ALIGNMENTS:** \u003cbr\u003e `TOP`, `MIDDLE`, `BOTTOM`\n\n* **Enabling or disabling the close button:**\n```python\ntoast.setShowCloseButton(False)  # Default: True\n```\n\n* **Customizing the duration of the fade animations (milliseconds):**\n```python\ntoast.setFadeInDuration(100)   # Default: 250\ntoast.setFadeOutDuration(150)  # Default: 250\n```\n\n* **Enabling or disabling duration reset on hover:**\n\n```python\ntoast.setResetDurationOnHover(False)  # Default: True\n```\n\n* **Making the corners rounded:**\n```python\ntoast.setBorderRadius(3)  # Default: 0\n```\n\n* **Setting custom colors:**\n```python\ntoast.setBackgroundColor(QColor('#292929'))       # Default: #E7F4F9\ntoast.setTitleColor(QColor('#FFFFFF'))            # Default: #000000\ntoast.setTextColor(QColor('#D0D0D0'))             # Default: #5C5C5C\ntoast.setDurationBarColor(QColor('#3E9141'))      # Default: #5C5C5C\ntoast.setIconColor(QColor('#3E9141'))             # Default: #5C5C5C\ntoast.setIconSeparatorColor(QColor('#585858'))    # Default: #D9D9D9\ntoast.setCloseButtonIconColor(QColor('#C9C9C9'))  # Default: #000000\n```\n\n* **Setting custom fonts:**\n```python\n# Init font\nfont = QFont('Times', 10, QFont.Weight.Bold)\n\n# Set fonts\ntoast.setTitleFont(font)  # Default: QFont('Arial', 9, QFont.Weight.Bold)\ntoast.setTextFont(font)   # Default: QFont('Arial', 9)\n```\n\n* **Applying a style preset:**\n```python\ntoast.applyPreset(ToastPreset.ERROR)\n```\n\u003e **AVAILABLE PRESETS:** \u003cbr\u003e `SUCCESS`, `WARNING`, `ERROR`, `INFORMATION`, `SUCCESS_DARK`, `WARNING_DARK`, `ERROR_DARK`, `INFORMATION_DARK`\n\n* **Setting toast size constraints:**\n```python\n# Minimum and maximum size\ntoast.setMinimumWidth(100)\ntoast.setMaximumWidth(350)\ntoast.setMinimumHeight(50)\ntoast.setMaximumHeight(120)\n\n# Fixed size (not recommended)\ntoast.setFixedSize(QSize(350, 80))\n```\n\n\n**\u003cbr\u003eOther customization options:**\n\n| Option                        | Description                                                                     | Default                    |\n|-------------------------------|---------------------------------------------------------------------------------|----------------------------|\n| `setFixedScreen()`            | Fixed screen where the toasts will be shown (static)                            | `None`                     |\n| `setMovePositionWithWidget()` | Whether the toasts should move with widget if positioned relative to a widget   | `True`                     |\n| `setIconSeparatorWidth()`     | Width of the icon separator that separates the icon and text section            | `2`                        |\n| `setCloseButtonIcon()`        | Icon of the close button                                                        | `ToastIcon.CLOSE`          |\n| `setCloseButtonIconSize()`    | Size of the close button icon                                                   | `QSize(10, 10)`            |\n| `setCloseButtonSize()`        | Size of the close button                                                        | `QSize(24, 24)`            |\n| `setStayOnTop()`              | Whether the toast stays on top of other windows even when they are focused      | `True`                     |\n| `setTextSectionSpacing()`     | Vertical spacing between the title and the text                                 | `8`                        |\n| `setMargins()`                | Margins around the whole toast content                                          | `QMargins(20, 18, 10, 18)` |\n| `setIconMargins()`            | Margins around the icon                                                         | `QMargins(0, 0, 15, 0)`    |\n| `setIconSectionMargins()`     | Margins around the icon section (the area with the icon and the icon separator) | `QMargins(0, 0, 15, 0)`    |\n| `setTextSectionMargins()`     | Margins around the text section (the area with the title and the text)          | `QMargins(0, 0, 15, 0)`    |\n| `setCloseButtonMargins()`     | Margins around the close button                                                 | `QMargins(0, -8, 0, -8)`   |\n\n## Demo\nhttps://github.com/niklashenning/pyqt-toast/assets/58544929/f4d7f4a4-6d69-4087-ae19-da54b6da499d\n\nThe demos for PyQt5, PyQt6, and PySide6 can be found in the [demo](demo) folder.\n\n## Tests\nInstalling the required test dependencies [PyQt6](https://pypi.org/project/PyQt6/), [pytest](https://github.com/pytest-dev/pytest), and [coveragepy](https://github.com/nedbat/coveragepy):\n```\npip install PyQt6 pytest coverage\n```\n\nTo run the tests with coverage, clone this repository, go into the main directory and run:\n```\ncoverage run -m pytest\ncoverage report --ignore-errors -m\n```\n\n## License\nThis software is licensed under the [MIT license](https://github.com/niklashenning/pyqttoast/blob/master/LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fniklashenning%2Fpyqttoast","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fniklashenning%2Fpyqttoast","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fniklashenning%2Fpyqttoast/lists"}