I have a dictionary of QPushButtons, I am trying to change the text when a certain push button is pressed, but it keeps only changing the last button. I think the issue is that every time 3 gets passed, I have no idea why that would be the case though. My code looks like this:
class App(QWidget):
def __init__(self):
super().__init__()
self.buttons = {}
for x in range(1, 4):
self.buttons[x] = QPushButton(self)
self.buttons[x].setText("TestButton")
self.buttons[x].resize(70, 30)
self.buttons[x].move(40, 40*x)
self.buttons[x].clicked.connect(lambda: self.ButtonPressed(x))
self.show()
def ButtonPressed(self, x):
self.buttons[x].setText("Text Changed!")