Issue
import sys
from PyQt4.QtGui import *
app = QApplication(sys.argv)
w = QWidget()
w.resize(250,150)
w.move(300,300)
w.setWinowTitle(('hey'))
w.show()
sys.exit(a.exec_())
Traceback (most recent call last): File "gu.py", line 9, in w.setWinowTitle(('hey')) AttributeError: 'QWidget' object has no attribute 'setWinowTitle'
I am using Windows and installed pyqt using t binary installer.
Solution
Do it in right way :)
import sys
from PyQt4 import QtGui
class ExampleWidget(QtGui.QWidget):
def __init__(self):
super(ExampleWidget, self).__init__()
self.setWindowTitle('Hey')
self.show()
def main():
qtApp = QtGui.QApplication(sys.argv)
wid = ExampleWidget()
sys.exit(qtApp.exec_())
if __name__ == '__main__':
main()
And avoid importing using * its not good practice
As request here is the working version of your code.
import sys
from PyQt4.QtGui import *
app = QApplication(sys.argv)
w = QWidget()
w.resize(250,150)
w.move(300,300)
w.setWindowTitle(('hey'))
w.show()
sys.exit(app.exec_())
You had aa typo setWindowTitle not setWinowTitle :) and you declared QApplication as app and you were exec with a.
Answered By - Achayan
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.