If you plan to use Ui file, you don't need to compile it to python. Doing the conversion in the script will make your workflow much easier. You can use Qt's uic utility like this:
If you really want to convert it, you must first import it in your script, then in __init__:
#!/usr/bin/python3 import os import sys from PyQt5 import QtCore, QtGui, QtWidgets, uic LOCAL_DIR = os.path.dirname(os.path.realpath(__file__)) class Main(QtWidgets.QMainWindow): def __init__(self): super().__init__() self.ui = uic.loadUi(LOCAL_DIR + "/foo.ui", self) self.show() print(self.ui.inputPipe_name.text()) if __name__== '__main__': app = QtWidgets.QApplication([]) gui = Main() sys.exit(app.exec_())The only downside is that it takes more time to execute, but if you plan the distribute the package, the ui files can be converted only once at install time.
If you really want to convert it, you must first import it in your script, then in __init__:
self.ui = foo.Ui_MainWindow() # Or .Ui_Dialog, or .Ui_Widget self.ui.setupUi(self)Then access yours widgets trought the self.ui object, as in the previous example