Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yjg30737/pyqt-tooltip-widget
PyQt QWidget as a tooltip
https://github.com/yjg30737/pyqt-tooltip-widget
pyqt pyqt-examples pyqt-tutorial pyqt5 pyqt5-examples qenterevent qleaveevent qt qt5 qtooltip
Last synced: about 2 months ago
JSON representation
PyQt QWidget as a tooltip
- Host: GitHub
- URL: https://github.com/yjg30737/pyqt-tooltip-widget
- Owner: yjg30737
- License: mit
- Created: 2022-04-06T01:52:42.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2022-05-13T22:25:20.000Z (almost 3 years ago)
- Last Synced: 2024-12-25T14:03:28.192Z (about 2 months ago)
- Topics: pyqt, pyqt-examples, pyqt-tutorial, pyqt5, pyqt5-examples, qenterevent, qleaveevent, qt, qt5, qtooltip
- Language: Python
- Homepage:
- Size: 26.4 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# pyqt-tooltip-widget
PyQt QWidget as a tooltip## Requirements
* PyQt5 >= 5.8## Setup
`python -m pip install pyqt-tooltip-widget`## Detailed Description
This is `QWidget` which is activated like tooltip. When mouse cursor enters to the widget, `ToolTipWidget` pops up at the bottom left of the widget. Leave from the widget tooltip will be disappeared.I made it work by catching `QEnterEvent` and `QLeaveEvent` of widget.
`ToolTipWidget` inherits `QWidget`, so you can decorate it just like `QWidget`.
### Usage
Just make instance of it like `self.toolTip = ToolTipWidget(yourWidget)`. `yourWidget` argument is the widget which you want to set tooltip of. Instance should be class variable.
### Method Overview
* `setStillOpenWhenCursorLeaveFromToolTipWidget(f: bool)` - Tooltip will be kept showing when cursor is inside the tooltip. (this is disabled by default)
* `isStillOpenWhenCursorLeaveFromToolTipWidget() -> bool`## Example
Code Sample
```python
from PyQt5.QtWidgets import QWidget, QMainWindow, QHBoxLayout, QPushButton, QApplication, QVBoxLayout
from pyqt_date_table_widget import DateTableWidget
from pyqt_tooltip_widget import ToolTipWidgetclass MainWindow(QMainWindow):
def __init__(self):
super().__init__()
self.__initUi()def __initUi(self):
btn = QPushButton('Show Date Table Widget')
lay = QHBoxLayout()
lay.addWidget(btn)mainWidget = QWidget()
mainWidget.setLayout(lay)### Make tooltip start ###
dateTableWidget = DateTableWidget() # https://github.com/yjg30737/pyqt-date-table-widget.git
lay = QVBoxLayout()
lay.addWidget(dateTableWidget)
lay.setContentsMargins(0, 0, 0, 0)self.__tooltip = ToolTipWidget(btn)
self.__tooltip.setFixedSize(200, 200)
self.__tooltip.setLayout(lay)
### Make tooltip end ###self.setCentralWidget(mainWidget)
if __name__ == "__main__":
import sysapp = QApplication(sys.argv)
example = MainWindow()
example.show()
app.exec_()```
Result
![image](https://user-images.githubusercontent.com/55078043/161909861-a724e0c5-4b16-4fa0-ab0b-7144b1386d82.png)