title: Bind variable number of PyQt toggles to same number of functions
body: <p>I currently have a problem with PyQt5 on Python 3.9.7 (macOS): the code below creates a layout containing a variable number of qtwidgets toggles (and it works correctly).</p>
  <pre><code>layout_list = []
  for gesture in settings['Gestures']:
      layout = QHBoxLayout()
  
      gesture_name = QLabel(gesture)
      layout.addWidget(gesture_name)
  
      toggle = Toggle(checked_color = &quot;#00AA00&quot;)
      layout.addWidget(toggle)
  
      self.gesture_toggle_list.append((gesture, toggle))
      layout_list.append(layout)
          
  self.gestureSelector = QVBoxLayout()
  for layout in layout_list:
      self.gestureSelector.addLayout(layout)
  </code></pre>
  <p>Then, I have to bind each toggle to a different function (or to the same function but with different parameters), so I did this:</p>
  <pre><code>for gesture, toggle in self.gesture_toggle_list:
      // Prints each gesture and toggle id correctly
      print(gesture, str(toggle))
      toggle.clicked.connect(lambda: self.toggleGesture(gesture))
  </code></pre>
  <p>and then:</p>
  <pre><code>def toggleGesture(self, gesture):
      // Should print the gesture related to the toggle clicked
      print(gesture)
  </code></pre>
  <p>Unfortunately, whenever I click on one of the toggles, the gesture printed is not the one related to the toggle, but is always the last one on the list (the last gesture seems to override all the others).</p>
  <p>Is there a way to fix this problem?</p>