PyQt5 failing import of QtGui

Assuming everything was installed correctly, you need to adjust your imports slightly to port from PyQt4 to PyQt5. The main GUI elements are in the QtWidgets module, whilst the more basic GUI elements are in QtGui. See the Qt modules page for more details. The example code needs to be changed to something like: from … Read more

No name ‘QApplication’ in module ‘PyQt5.QtWidgets’ error in Pylint

I’ve figured out the issue, apparently Pylint doesn’t load any C extensions by default, because those can run arbitrary code. So I found that if you create a system file in your project directory with the file named .pylintrc the rc file can whitelist this package to stop throwing errors by adding the following code … Read more

time.sleep() and BackGround Windows PyQt5

An expression equivalent to time.sleep(2) that is friendly to PyQt is as follows: loop = QEventLoop() QTimer.singleShot(2000, loop.quit) loop.exec_() The problem is caused because you are showing the widget after the pause, you must do it before calling run(), Also another error is to use QImage, for questions of widgets you must use QPixmap. If … Read more

Connect to serial from a PyQt GUI

Instead of using pySerial + thread it is better to use QSerialPort that is made to live with the Qt event-loop: from PyQt5 import QtCore, QtWidgets, QtSerialPort class Widget(QtWidgets.QWidget): def __init__(self, parent=None): super(Widget, self).__init__(parent) self.message_le = QtWidgets.QLineEdit() self.send_btn = QtWidgets.QPushButton( text=”Send”, clicked=self.send ) self.output_te = QtWidgets.QTextEdit(readOnly=True) self.button = QtWidgets.QPushButton( text=”Connect”, checkable=True, toggled=self.on_toggled ) lay = … Read more