Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PyQt5 cannot import name 'QApplication'

Tags:

python

pyqt5

I am trying convert my code from PyQt4 to PyQt5 but I am getting errors.

from PyQt5.QtGui import QApplication, QPixmap desktop = QApplication.desktop() QPixmap.grabWindow(desktop.screen().winId()).save("screen.png", "PNG")   3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:44:40) [MSC v.1600 64 bit (AMD64)] Traceback (most recent call last):   File "C:\Python34\Projects\name.py", line 7, in <module>     from PyQt5.QtGui import QApplication, QPixmap ImportError: cannot import name 'QApplication' 
like image 433
Arthur Yakovlev Avatar asked Mar 25 '15 15:03

Arthur Yakovlev


1 Answers

QApplication is located in PyQt5.QtWidgets module. So your import statement should be:

from PyQt5.QtWidgets import QApplication 
like image 169
styvane Avatar answered Sep 19 '22 00:09

styvane