Compile py project with ui.ui file of pyqt5

Hi all,

I have created a project with a py file in which I used pyqt5 library. The UserInterface has been created with qt designer.

from PyQt5.QtWidgets import QApplication, QMainWindow, QWidget
from PyQt5 import uic
class Ui(QMainWindow):

    def __init__(self):
        uic.loadUi('./ui/ui.ui', self)

app = QApplication([])
window = Ui()

the file ui is located in ./ui/ui.ui

I would compiule the project and run it on windows 10 or linux system or android. I would compile it because I don’t want pass source code and avoid someone changed it.

Can someone explain me how to compile the project and run it on the different operating system or suggest to me some tutorials or example?

many thanks
Best Regards

This isn’t really a topic for the Python forums since it’s specific to one (third-party) library, but for starters if you don’t want to distribute your UI file you should look at the pyuic5 tool that comes with PyQt5, it can process your .ui file into a Python .py module (the same way Qt’s uic processes it into a C++ class file).

From there, you can take a look at cx_Freeze which has examples specifically covering PyQt5 applications. Or there’s Riverbank’s (publishers of PyQt5) own pyqtdeploy.

1 Like