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'
QApplication
is located in PyQt5.QtWidgets
module. So your import statement should be:
from PyQt5.QtWidgets import QApplication
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With