class MainMenu(QWidget):
def __init__(self):
# QWiget constructor
super().__init__()
self.initUI()
def initUI(self):
self.buttons = (QPushButton('Uebergang'), QPushButton('Scherung'), QPushButton('Wippe'))
self.layout = QVBoxLayout()
for button in self.buttons:
self.layout.addWidget(button)
func = lambda : self.openMenu(button.text())
button.clicked.connect(func)
self.setLayout(self.layout)
self.show()
def openMenu(self, Menu):
print(Menu)
When I click on any of the three buttons it always prints "Wippe". I don't understand why. I know this question has been answered before but the answers didn't solve my problem.