I have a method setupUi()
in Ui_MainWindow
in design.py
(its a really long method created by PyQt Designer)
class Ui_MainWindow(object):
def setupUi(self, MainWindow): # really long method
self.xyz
...
...
and would like to use it as if it were a method in my main file app.py
in the ApplicationWindow
class.
What I want to imitate:
class ApplicationWindow:
def __init__(self, MainWindow, truss, *args, **kwargs):
self.setupUi(MainWindow)
[use self.xyz here]
...
def setupUi(self, MainWindow): # same really long method I want here
...
...
What I tried:
from design import Ui_MainWindow
class ApplicationWindow:
def __init__(self, MainWindow, truss, *args, **kwargs):
Ui_MainWindow().setupUi(MainWindow) # this works
[use self.xyz here] # this does not work
...
...
I want to use the variable self.xyz
from Ui_MainWindow
in the ApplicationWindow
class.
But I get an AttributeError
for self.xyz
.
Again, the reason that I want it in a seperate file, is because it's very long.
I'm sure this is a simple fix, as modules work in a similar way. But for some reason it isn't working for me, any ideas?
How I call the function (everything is in OOP/Functional):
if __name__ == "__main__":
import sys
qapp = QtWidgets.QApplication(sys.argv)
MainWindow = QtWidgets.QMainWindow()
truss = FEModel3D
app = ApplicationWindow(MainWindow, truss)
MainWindow.show()
sys.exit(qapp.exec_())
File structure:
master
├───app.py
├───...
└───design.py