
Security News
Meet Socket at Black Hat and DEF CON 2025 in Las Vegas
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
PyQt QWidget as a tooltip
python -m pip install pyqt-tooltip-widget
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
.
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.
setStillOpenWhenCursorLeaveFromToolTipWidget(f: bool)
- Tooltip will be kept showing when cursor is inside the tooltip. (this is disabled by default)
isStillOpenWhenCursorLeaveFromToolTipWidget() -> bool
Code Sample
from PyQt5.QtWidgets import QWidget, QMainWindow, QHBoxLayout, QPushButton, QApplication, QVBoxLayout
from pyqt_date_table_widget import DateTableWidget
from pyqt_tooltip_widget import ToolTipWidget
class 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 sys
app = QApplication(sys.argv)
example = MainWindow()
example.show()
app.exec_()
Result
FAQs
PyQt QWidget as a tooltip
We found that pyqt-tooltip-widget demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.