Reputation: 260
I started reading the zetcode tutorial for PyQt4 (http://zetcode.com/tutorials/pyqt4/firstprograms/) and I was doing the tooltip part and all I did was copy and paste this bit of code. When I went to run it, the push button did not display in the window. Any reason as to why this might be? new to PyQt4 and Qt in general.
import sys
from PyQt4 import QtGui
class Example(QtGui.QWidget):
def __init__(self):
super(Example, self).__init__()
self.initUI()
def initUI(self):
QtGui.QToolTip.setFont(QtGui.QFont('SansSerif', 10))
self.setToolTip('This is a <b>QWidget</b> widget')
btn = QtGui.QPushButton('Button, self')
btn.setToolTip('This is a <b>QPushButton</b> widget')
btn.resize(btn.sizeHint())
btn.move(50, 50)
self.setGeometry(300, 300, 250, 150)
self.setWindowTitle('Tooltips')
self.show()
def main():
app = QtGui.QApplication(sys.argv)
ex = Example()
sys.exit(app.exec_())
if __name__ == '__main__':
main()
Upvotes: 1
Views: 1379
Reputation: 1500
btn = QtGui.QPushButton('Button, self')
supposed to be:
btn = QtGui.QPushButton('Button', self)
Upvotes: 3
Reputation: 369424
Replace following line:
btn = QtGui.QPushButton('Button, self')
with:
btn = QtGui.QPushButton('Button', self)
Upvotes: 4