Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yjg30737/pyqt-toast
PyQt Toast (Small message displayed on the screen, visible for a short time)
https://github.com/yjg30737/pyqt-toast
pyqt pyqt-examples pyqt-toast pyqt-tutorial pyqt5 pyqt5-examples pyqt5-gui pyqt5-toast pyqt5-tools pyqt5-tutorial python python3 python37 qt qt-toast toast
Last synced: about 18 hours ago
JSON representation
PyQt Toast (Small message displayed on the screen, visible for a short time)
- Host: GitHub
- URL: https://github.com/yjg30737/pyqt-toast
- Owner: yjg30737
- License: mit
- Created: 2021-12-25T01:14:44.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-03-20T01:05:54.000Z (10 months ago)
- Last Synced: 2024-12-20T17:11:54.459Z (14 days ago)
- Topics: pyqt, pyqt-examples, pyqt-toast, pyqt-tutorial, pyqt5, pyqt5-examples, pyqt5-gui, pyqt5-toast, pyqt5-tools, pyqt5-tutorial, python, python3, python37, qt, qt-toast, toast
- Language: Python
- Homepage:
- Size: 55.7 KB
- Stars: 12
- Watchers: 1
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# pyqt-toast
PyQt Toast (Small message displayed on the screen, visible for a short time)## Help Wanted
If you are good at PyQt, i kindly ask you to make setDuration work :)## Requirements
PyQt5 >= 5.14## Setup
`python -m pip install pyqt-toast`## Usage
* ```Toast(text='This is toast', duration=3, parent=self)``` - Constructor. Giving ```parent``` argument to ```self``` value helps toast to maintain its place after window got moved.Note: You have to declare this one time as a class variable at initializing point(e.g. ```__initUi```) or else new one will pop up even though last one is still showing.
* `setPosition(pos: QPoint)` - Place center of the toast at the given position.
* `setFont(font: QFont)` - Set the font of text in toast. Toast's size will be automatically changed based on text's size.
* `setForegroundColor(color)` - Set the text(foreground) color. `color` argument can be both `str`(6-digits hex color string), `QColor` types.
* `setBackgroundColor(color)` - Set the background color. `color` argument can be both `str`(6-digits hex color string), `QColor` types.
* `setOpacity(opacity: float)` - Set the opacity of toast.
* `setDuration(duration: int)` - Set the duration of toast. - This doesn't work currently ..
* `setAlignment(alignment)` - Set the alignment of text.## Example
Code Sample
```python
from PyQt5.QtWidgets import QWidget, QApplication, QPushButton, QGridLayoutfrom pyqt_toast import Toast
class ToastExample(QWidget):
def __init__(self):
super().__init__()
self.__initUi()def __initUi(self):
btn = QPushButton('Krabby Patty secret formula')
self.__toast = Toast(text='The Krabby Patty formula is the sole property of the Krusty Krab and is only to be discussed in part or in whole with its creator Mr. Krabs. Duplication of this formula is punishable by law. Restrictions apply, results may vary.', duration=3, parent=self)
btn.clicked.connect(self.__toast.show)
lay = QGridLayout()
lay.addWidget(btn)
self.setLayout(lay)if __name__ == "__main__":
import sysapp = QApplication(sys.argv)
toastExample = ToastExample()
toastExample.show()
app.exec_()
```Result
https://user-images.githubusercontent.com/55078043/163155105-371e5d88-8b77-4a25-90cc-5c461f841762.mp4