I am creating a keyboard in TKinter. pressing a button should just print out the text for that button. For some reason every button prints out ctrl which is the last button created. How do I change it so that it actually prints out the respective text for each button?
def press(key):
print(key)
def createWidgets(self):
for tup in layout.layout:
for key, value in tup:
button = Button(self, text=key, command=lambda: self.press(key))
self.kboard_buttons.append(button)
button.pack(side="left")
print(key)
that is misindented, if such a word exists... – gboffilambda k=key: self.press(k)
and let us know of your findings? – gboffi