What I'm trying to do is to create checkboxes using for loop and connect a function to them ,which is called with different argument for every checkbox.
Here is some code:
for video in videos:
video_cb = QtGui.QCheckBox(video['title'])
video_cb.toggle()
video_cb.stateChanged.connect(lambda: self._toggle_video_cb(video))
videos_checkboxes_container.addWidget(video_cb)
and _toggle_video_cb function:
def _toggle_video_cb(self, video):
print(video['title'])
video['is_for_download'] = not video['is_for_download']
Here video
is a dictionary whith keys: title: (str) , is_for_download: (boolean)...
The print
is just for checking the argument and it is the same for every checkbox.No matter which checkbox I click it gives me it prints the same video title.
Why is that so? Is that the right way to do it?
Thanks in advance !
Best regards :)