I have created a PyQt6 form with the designer and can convert to py file and it runs. I would prefer just loading the ui file into a class in python. I have several different examples of this and they all fail on the same line “load_ui”
The error I get is
Traceback (most recent call last): File "c:Usersxxx.xxDocumentsPythonUI_TestTest_Formv2.py", line 19, in <module> ui = MainUI() ^^^^^^^^ File "c:Usersxxx.xxDocumentsPythonUI_TestTest_Formv2.py", line 9, in __init__ uic.load_ui("Test_Form.ui", self) TypeError: 'module' object is not callable
Here is my code:
import sys
from PyQt6.QtWidgets import QApplication, QMainWindow
from PyQt6 import uic #PyQt6.uic import load_ui
class MainUI(QMainWindow):
def __init__(self):
super(MainUI, self).__init__()
uic.load_ui("Test_Form.ui", self)
self.pbLOADSTIG.clicked.connect(self.pbLOADSTIG_Clicked)
def pbLOADSTIG_Clicked(self):
print ("STIG LOAD button clicked")
if __name__ == "__main__":
app = QApplication(sys.argv)
ui = MainUI()
ui.show()
app.exec()
This is my first attempt at using PyQT6. So far it had looked good. Found 3 different examples of loading the .ui file, but each version failed on the same load. I have verified that the base class in the designer is a QMainWindow
Bob Morse is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.