I'm trying to make some new QPushButton
from list of rows and then connect them to an Event Handler Function
using connect
but no matter what i do, i can't connect them separately to the function.
the code is like this
def addItemButtons(self,chosen):
# ----------- DELETE OLD BUTTONS ------------
for i in reversed(range(self.layoutbottom.count())):
self.layoutbottom.itemAt(i).widget().setParent(None)
# ----------- MAKE A NEW BUTTON FOR EACH CHOSEN ENTRY -----------
for d in chosen:
itembtn = QPushButton("ID : "+str(d['id']))
itembtn.clicked.connect(lambda : self.handlerFunction(str(d['id'])))
self.layoutbottom.addWidget(itembtn)
def handlerFunction(self,txt):
print(txt)
when I click on new buttons the handlerFucntion
just prints the last button id
!
I searched and used different methods for connecting buttons to handlerFunction but all were the same.
what is it that I am doing wrong? :/