I'm struggling to understand the general structure of how to work with PyQt. I want to have my main file
class MainWindow(qtw.QMainWindow):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
if __name__ == '__main__':
app = qtw.QApplication([])
widget = MainWindow()
widget.show()
app.exec_()
separate from the ui-file
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.horizontalLayout = QtWidgets.QHBoxLayout(self.centralwidget)
self.horizontalLayout.setObjectName("horizontalLayout")
self.LeftSide = QtWidgets.QWidget(self.centralwidget)
self.LeftSide.setObjectName("LeftSide")
self.verticalLayout = QtWidgets.QVBoxLayout(self.LeftSide)
self.excel.setObjectName("something")
self.verticalLayout.addWidget(self.something)
...
as I want to be able to change the ui later on but retain all functionality. The UI has widgets within widgets.
How do I access these widgets in the separate main.py file or in separate files and add functionality, preferably by creating a class for each widget?
Thanks a lot for any help!