Issue
I'm new to python and following this tutorial:
https://zetcode.com/pyqt6/firstprograms/
Based on the tutorial, I'm trying to use PyQT6 to create a simple window with a button:
#!/usr/bin/python
import sys
from PyQt6.QtCore import QT_VERSION_STR
from PyQt6.QtCore import PYQT_VERSION_STR
from PyQt6.QtWidgets import QWidget, QToolTip, QPushButton, QApplication
from PyQt6.QtGui import QFont
class Example(QWidget):
def __init__(self):
super().__init__()
self.initUI()
def initUI(self):
QToolTip.setFont(QFont('SansSerif', 10))
self.setToolTip('This is a <b>QWidget</b> widget')
btn = QPushButton('Button', self)
btn.setToolTip('This is a <b>QPushButton</b> widget')
btn.resize(btn.sizeHint())
btn.move(50, 50)
self.setGeometry(300, 300, 300, 200)
self.setWindowTitle('Tooltips')
self.show()
def main():
print(QT_VERSION_STR)
print(PYQT_VERSION_STR)
app = QApplication(sys.argv)
ex = Example()
sys.exit(app.exec())
if __name__ == '__main__':
main()
The window and button pop up for me, but nothing happens when I click on it, no tooltips or anything. Does anyone know why this might be the case?
Solution
The tooltip does show with the code you have.
To make the tooltip pop-up hover over the button for a few seconds.
Answered By - RossM
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.