Skip to content Skip to sidebar Skip to footer

Pyqt5 Program Created With Qtdesigner Doesnt Show Any Window When Opened From Terminal

I was working with QT Designer with no issues but today i started a fresh ubuntu 18.04 install, but this time when i run the PyQt5 programs from terminal they doesnt show any windo

Solution 1:

To generate a code that can show a window using pyuic you must use the -x option:

pyuic5 input.ui -o output.py -x

The previous command using the -x adds the following code to the end of the file:

if__name__== "__main__":
    importsysapp= QtWidgets.QApplication(sys.argv)
    MainWindow = QtWidgets.QMainWindow()
    ui = Ui_MainWindow()
    ui.setupUi(MainWindow)
    MainWindow.show()
    sys.exit(app.exec_())

Solution 2:

pyuic5 input.ui -o output.py -x

I create a GUI that is missing pyuic5.exe file, I tried all the way to have Google platform but it could not work. Then I uninstalled python and QT, I reinstalled it then I used

pyuic5 input.ui -o output.py -x

Thus the result is a good UI file converted into .py file.

Post a Comment for "Pyqt5 Program Created With Qtdesigner Doesnt Show Any Window When Opened From Terminal"