I am currently using tkinter in order to make a poker simulation. I am trying to give each hand(which are represented by buttons which are cards) a text to represent how much money they have. Below is the code for dealing out the hands and where the money is returned.
#This deals the card to each of the players
def dealCard():
'''Deals the Card to Each of the players'''
global handCount, cards, cardSuit, cardRank, hand
for i in range(amountOfPlayers):
hand = []
while handCount < 2:
card = changeCardHand()
cardSuit = str(card.suit)
cardRank = str(card.rank)
cardImage = showCard(cardSuit, cardRank, width= 75, height = 100)
image_listHand.append(cardImage)
backImage = Image.open(f"PNG-cards-1.3/card_back_black.png")
backImage = backImage.resize((75, 100))
backImage = ImageTk.PhotoImage(backImage)
back_imageList.append(backImage)
cardButton = tkinter.Button(canvas, image = backImage, text = "0", compound = "bottom", command = lambda index = image_listHand.index(cardImage): [flipImage(index)])
cardButton.config(text = lambda index = i: [getPlayerMoney(index)])
button_list.append(cardButton)
cardButton.place(x = (-25 * amountOfPlayers) + (50*(2*i+1) + 120*(i + 1)) + (handCount + 1)*80, y = (300))
handCount = handCount + 1
hand.append(card)
cards.append(hand)
handCount = 0
And here is the code to return the money
def getPlayerMoney(index):
return str(money[index])
And this is the code which uses an Entry to set the amount of money everyone starts with.
def loadMoney():
'''Loads the money into each of the players hands'''
global potValue
potValue = int(potEntry.get())
for i in range(amountOfPlayers):
money.append(potValue)
potEntry.destroy()
However, instead of the monetary value showing up, each card’s text is instead a lambda string as such
How do I fix this issue?