I'm fairly new to python, and I feel this is an advanced question, with that in mind it might be out of the scope of Stack Exchange. Please bear with me.
I have a QTreeWidget and QStackedWidget. I have populated the QTreeWidget using a tuple
TreeList = ({
'Header1': ((
'Item11',
'Item12',
)),
'Header2': ((
'Item21',
'Item22'
))
})
for key, value in TreeList.items():
root = QTreeWidgetItem(self.QTreeWidget, [key])
for val in value:
root.addChild(QTreeWidgetItem([val]))
I would like to use this same tuple to populate a QStackedWidget with pages that correspond with the QTreeWidget and establish signals and slots with in the same loop. I have tried using:
for key in TreeList['Item1']:
page = QWidget()
page.setObjectName(key)
self.QStackedWidget.addWidget(page)
print(self.QStackedWidget)
but all of the objects point to the same hex value, which I assume means they are not unique. Perhaps I need to increment the index? In either case I have not been able to figure out how to generate the signals and slots while doing this, since they are being dynamically created and I need unique but predictable names.
The idea is that by simply adding a new category or item to the tuple, the QTreeView, QStackedWidget, and signals / slots are all generated at runtime without having to modify any source code beyond the tuple.
What would be the best way to accomplish this?
Sorry if this is too much, but I figured it might be a good question in case anyone else attempts the same thing at a later time.
EDIT: I'm using Python 3.6 and PyQt5