[PyQt] Problem sometimes connecting signal/slot in a loop
Luna Tuna
fruitfulapproach at gmail.com
Thu May 16 22:42:44 BST 2019
Hi,
Codes:
def setup(self):
for color in self._colors:
attr = color + ' color button'
attr = attr.replace(' ', '_')
button = getattr(self, attr)
self._buttons[color] = button
button.clicked.connect(lambda: self.show_color_dialog(color))
When you do something like this, then all connections are made to the last
color in the list,
so clicking on "pen" color will always change "edit locked label" color
(the last in list).
I've fixed it before by making the connection in a dummy function. But is
there a better way to resolve this?
Thanks.
-Fruitful Approach
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20190516/92691893/attachment.html>
More information about the PyQt
mailing list