Skip to main content

PyQt QWidget as a tooltip

Project description

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

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

image

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyqt-tooltip-widget-0.0.1.tar.gz (3.4 kB view details)

Uploaded Source

Built Distribution

pyqt_tooltip_widget-0.0.1-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file pyqt-tooltip-widget-0.0.1.tar.gz.

File metadata

  • Download URL: pyqt-tooltip-widget-0.0.1.tar.gz
  • Upload date:
  • Size: 3.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/0.0.0 CPython/3.7.6

File hashes

Hashes for pyqt-tooltip-widget-0.0.1.tar.gz
Algorithm Hash digest
SHA256 7f5dad1d14e41bc644b048026cd4b5e84df184c60ecb64d9da6828e655464765
MD5 c9ddca21eddbd593e6a6e10661c22549
BLAKE2b-256 40101989f8482acddcd06c238f7794d4d0d131c5c9c6ea476c280aefd05b7a42

See more details on using hashes here.

File details

Details for the file pyqt_tooltip_widget-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for pyqt_tooltip_widget-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3a554b8201f51dc9c3e2cc79785e3d961336db4cc21c5114f14d20fd19c473b4
MD5 5f9a073f62427a7bb26f1dae52426f21
BLAKE2b-256 09cdc6f4df3c6d69042c969fdae6d3300faefee4dfb5490ff42ec80c6bbd6db0

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page