Oct-05-2019, 07:04 PM
(This post was last modified: Oct-05-2019, 07:04 PM by riccardoob.)
Thanks for the side note. self.hands_inputs is the argument of player.fold() because fold is the function that's supposed to delete from the tkinter window (usinf the command widget.grid_forget()) some widget: the list phands_inputs is a list with 3 items, the first and the second one are filled with the names of the two cards in the hand of the player, the third item is filled with a list filled with button, so I pass the first 3 items of self.hands_inputs to then use them in the fold function inside a for statement to delete the widget from the window. More clearly, in the window I have let's say 5 rows: each one has two labels with the names of the two cards and a fold button, when I hit the fold button the line should disappear.
EDIT!!!!!:
I just noticed that using the for statement like I show in the code above the command tied to every button is alway referring to the last player (in the case I'm testing now the player with index 4), but if I do not use the for statement and do it the 'dummy' way, like that to be clear:
EDIT!!!!!:
I just noticed that using the for statement like I show in the code above the command tied to every button is alway referring to the last player (in the case I'm testing now the player with index 4), but if I do not use the for statement and do it the 'dummy' way, like that to be clear:
self.hands_inputs[2].append(Button(self.window, text='Fold', command = lambda: pplayers[0].fold(self.hands_inputs[0:3]))) self.hands_inputs[2].append(Button(self.window, text='Fold', command = lambda: pplayers[1].fold(self.hands_inputs[0:3]))) self.hands_inputs[2].append(Button(self.window, text='Fold', command = lambda: pplayers[2].fold(self.hands_inputs[0:3]))) self.hands_inputs[2].append(Button(self.window, text='Fold', command = lambda: pplayers[3].fold(self.hands_inputs[0:3]))) self.hands_inputs[2].append(Button(self.window, text='Fold', command = lambda: pplayers[4].fold(self.hands_inputs[0:3])))it works perfectly, but I need to do it with a for statement because the number of player is variable.