I have a problem with my tkinter code. That's what I got so far:
from tkinter import *
root = Tk()
def create_button():
liste = [['Name 1', 'Name 2', 'Name 3'], ['Name 4', 'Name 5', 'Name 6']]
#giving any button a diffrent command by changing the 'group'-parameter from the function show_player
for i in range(len(liste)):
Button_name = 'Group ' + str(i+1)
Button(root, text = Button_name, bg = 'white', command= lambda:[show_player(liste, i)]).pack()
def show_player(list1, group):
for name in list1[group]:
Label(root, text = name).pack()
create_button()
root.mainloop()
Regradless of which button I'm pressing, I get the names "Name 4", "Name 5", "Name 6",
but I expected the first button to create the labels with the names "Name 1", "Name 2", "Name 3"
Does anyone know why it doesn't work?