import problem under PyCharm uic is not found
-
have an import problem under PyCharm uic is not found
OS: Ubuntu 20.04import sys from PyQt5 import QtCore, QtGui, QtWidgets, uic class MainWindow(QtWidgets.QMainWindow): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) loadUi("first_test.ui") app = QtWidgets.QApplication(sys.argv) window = MainWindow() window.show() app.exec_()
PyQt5 5.15.4
pyqt5-plugins 5.15.4.2.2
PyQt5-qt5 5.15.2
PyQt5-sip 12.11.0
pyqt5-tools 5.15.4.3.2Any Ideas
Thanks
McAce
-
Hi and welcome to devnet,
uic is a command line tool, it's not something you import.
It might not be completely accurate in the case of PyQt5, see answer below for more details.
[edit: added more details SGaist]
-
Hi,
@TheNoodleNator said in import problem under PyCharm uic is not found:
@SGaist Hi, if it wasnt meant to be imported. Why is there documentation found here that shows us how to import it?
I learned something new, thanks !
It's something that is specific to PyQt5 and quite frankly I have never came across it until now. From a quick look, it does not seem to be documented as public API to be used by Qt applications.
The main things I found boils down to:python3 -m PyQt5.uic.pyuic mywidget.ui -o mywidget.py
The standard way to use .ui files is through the QtDesigner module either by usingpyuic5
to generate a python file from your .ui file or use of the QUiLoader class. See here for a more detailed explanation.