Как мне выводить обновляемую сумму массива в TKinter
Ну в ютубе увидел игру БлэкДжек (Просто которая запускается в терминале) и решил немного запарить себе мозги и создать приложение выше написанной игре . Так как я первый раз работаю с TKinter , у меня вообще не получается вывести сумму всех очков. По задумке выбирается рандомное число от 2 - 11 , добавляется в массив count и преобразовывается в рандомную игральную карту . Сам массив вроде бы заполняется , но не у меня никак не получается вывести его сумму , т.к вообще не понимаю как это делается . Вот сам код
from tkinter import *
import random
from tkinter import messagebox
a = [2,3,4,5,6,7,8,9,10,10,10,10,11] *4
random.shuffle(a)
bkoen = 0
biggame = 0
count = []
robot = 0
curent = 0
current = 0
robot_current = []
global_current = []
piki = ['?','?','?','?']
dva = ["?","?","?","?"]
three = ["?","?","?","?"]
four = ["?","?","?","?"]
five = ["?","?","?","?"]
six = ["?","?","?","?"]
seven = ["?","?","?","?"]
eigth = ["?","?","?","?"]
nine = ["?","?","?","?"]
ten = ["?","?","?","?","?","?","?","?","?","?","?","?","?","?","?","?"]
while True:
curent = a.pop()
robot += curent
if curent == 11 :
curent = random.choice(piki)
if curent == 2:
curent = random.choice(dva)
if curent == 3:
curent = random.choice(three)
if curent == 4:
curent = random.choice(four)
if curent == 5:
curent = random.choice(five)
if curent == 6:
curent = random.choice(six)
if curent == 7:
curent = random.choice(seven)
if curent == 8:
curent = random.choice(eigth)
if curent == 9:
curent = random.choice(nine)
if curent == 10:
curent = random.choice(ten)
robot_current.append(curent)
if robot < 17:
curent = a.pop()
robot += curent
if curent == 11 :
curent = random.choice(piki)
if curent == 2:
curent = random.choice(dva)
if curent == 3:
curent = random.choice(three)
if curent == 4:
curent = random.choice(four)
if curent == 5:
curent = random.choice(five)
if curent == 6:
curent = random.choice(six)
if curent == 7:
curent = random.choice(seven)
if curent == 8:
curent = random.choice(eigth)
if curent == 9:
curent = random.choice(nine)
if curent == 10:
curent = random.choice(ten)
robot_current.append(curent)
if robot > 16 and robot < 22:
break
if robot > 21:
robot = ">21"
break
def stop_give():
if robot == 0 :
robot == ">21"
print(f'У дилера {robot}')
if robot > count :
print('Вы проиграли')
elif robot == count :
print('Ничья')
else:
print("Вы победили")
def creategame():
game = Toplevel(root)
game.title('Игра')
game.geometry("1880x1260+0+0")
current = a.pop()
count.append(current)
if current == 11 :
current = random.choice(piki)
if current == 2:
current = random.choice(dva)
if current == 3:
current = random.choice(three)
if current == 4:
current = random.choice(four)
if current == 5:
current = random.choice(five)
if current == 6:
current = random.choice(six)
if current == 7:
current = random.choice(seven)
if current == 8:
current = random.choice(eigth)
if current == 9:
current = random.choice(nine)
if current == 10:
current = random.choice(ten)
global_current.append(current)
current = a.pop()
count.append(current)
if current == 11 :
current = random.choice(piki)
if current == 2:
current = random.choice(dva)
if current == 3:
current = random.choice(three)
if current == 4:
current = random.choice(four)
if current == 5:
current = random.choice(five)
if current == 6:
current = random.choice(six)
if current == 7:
current = random.choice(seven)
if current == 8:
current = random.choice(eigth)
if current == 9:
current = random.choice(nine)
if current == 10:
current = random.choice(ten)
global_current.append(current)
d.config(text = global_current)
print(*count)
def button_give():
current = a.pop()
count.append(current)
if current == 11 :
current = random.choice(piki)
if current == 2:
current = random.choice(dva)
if current == 3:
current = random.choice(three)
if current == 4:
current = random.choice(four)
if current == 5:
current = random.choice(five)
if current == 6:
current = random.choice(six)
if current == 7:
current = random.choice(seven)
if current == 8:
current = random.choice(eigth)
if current == 9:
current = random.choice(nine)
if current == 10:
current = random.choice(ten)
global_current.append(current)
d.config(text = global_current)
bkoen = sum(count)
root = Tk()
root.title('Главное меню')
root.geometry("600x300+150+150")
l = Label(text="Игра БлэкДжэк")
btn1 = Button(text='Игра', command=creategame)
game = Toplevel(root)
game.title('Игра')
game.geometry("1880x1260+0+0")
Button(game , command= button_give,text= "Взять карту").pack()
text1 = Label(game,text=bkoen , font= "Times 55").pack()
h = Label(game,text=robot_current ,font= "Times 80",width= 100 ).pack()
d = Label(game,text=global_current , font= "Times 80",height = 900,width= 50)
d.pack()
l.pack()
btn.pack()
btn1.pack()
root.mainloop()