def updateDataDictionary(self, opt, idx, param, check):
"""Populates the ScrollArea for Storage Enabling on Hub basis
:param opt: Option tells what to modify: technology(0) or storage(1)
:type opt: Integer
:param idx: The id for the hub which needs to be modified
:type idx: String
:param param: The Technology/Storage which needs to be modified
:type param: String
:returns: None
:rtype: None
"""
if(check.isChecked()):
if(opt == 1):
self.data_dictionary[idx]["Technologies"][param]["Enabled"] = "1"
elif(opt == 2):
self.data_dictionary[idx]["Storages"][param]["Enabled"] = "1"
else:
if(opt == 1):
self.data_dictionary[idx]["Technologies"][param]["Enabled"] = "0"
elif(opt == 2):
self.data_dictionary[idx]["Storages"][param]["Enabled"] = "0"
for i in range(len(self.data_dictionary.keys())):
temp_check = QCheckBox()
temp_check.setText(str(self.data_dictionary.keys()[i]))
if(self.data_dictionary[self.data_dictionary.keys(
)[i]]["Technologies"][self.dock_tab3_1.techCombo.currentText(
)]["Enabled"] == "1"):
# Make the Checkbox checked
temp_check.setChecked(True)
else:
# Make the Checkbox un-checked
temp_check.setChecked(False)
temp_check.stateChanged.connect(partial(
self.updateDataDictionary, 1, self.data_dictionary.keys()[i],
self.dock_tab3_1.techCombo.currentText(), temp_check))
temp_layout.addWidget(temp_check)
Here, I have a ScrollArea which has a list of checkboxes. The issue is that when on the GUI, a checkbox is toggled the updateDataDictionary method is being called for all the checkboxes in the scrollArea instead of only the one which was toggled.
So, ideally only one of the entry must go from 1 to 0, when corresponding check-box is toggled. But all of the entries in my dictionary get modified to 0.
How do I resolve this issue?