I have defined 2 Variables. The first one Works perfectly showing me all the Buttons with the Names of the People in my Global Array players.
I added the command line into my Button which is supposed to Activate my second def Variable once its clicked.The second Variable should save the Buttons Index or Text(tried both) and then i used print, to Display the Things it should save before i can move on.
Now here lies the Problem.
When i click on it , it shows me just an empty Array. I tried to use several other things like [i] instead of text , the btn which was assigned to the Buttons and i tried to Global the btn at one point because i could not use a non Global Variable inside my second function but that also didn't help.I read about partials and Lambda but i cant get my Head around the part that i need to Add/Change to get this going.
Here is my Code:
players=['x','y','z']
players_to_random=[]
def showButtons():
for i in players:
btn = Button(window, text=i, command=onclick)
btn.pack(side=LEFT)
def onclick():
players_to_random.append() # tried several things with () and without
print(players_to_random)
showButtons()