Sorry for an incoherent title, I don't know how to phrase this.
I'm using a for-loop to generate a bunch of alphabetical buttons in PyQt5. It looks something like this:
for i in range(0, 3): #rows
for j in range(0, 9): #columns
if i == 2 and j == 8: #27th iteration
break
letter = chr(letterStart) #letterStart = 65, capital "A"
if letterStart < 90:
letterStart += 1
buttons[letter] = [QPushButton(letter), letterStart]
buttons[letter][0].setStyleSheet(StyleSheets.buttonTypeSmall)
buttons[letter][0].clicked.connect(lambda: print(chr(letterButtonsDict[letter][1]))) #The part I'm having issues with
grid.addWidget(letterButtonsDict[letter][0], i, j)
If I print buttons
it will print excatly what I want, a dictionary with all my buttons as well as what letter they represent.
However, clicking them will not print their respective letter, only the last letter of the loop (Z). I have tried several different methods but without success.
How do I make it so that my "A-button" prints an A, and my "Z-button" prints a Z?