Не производятся вычисления в программе
я ОЧЕНЬ начинающий программист. Не производятся вычисления при нажатии на кнопку. Как это починить и почему. Гайды смотрел, не помогло. Заранее спасибо за помощь.
Вот, код программы, написан на Питоне.
from tkinter import *
root = Tk()
static = [0,0,0,0,0,0]
ost1 = 0
ran1 = 0
pot1 = 0
ost2 = 0
ran2 = 0
pot2 = 0
def b3_cal(damage, block, numbers, bonus, damage1, block1, numbers1, bonus1):
helper = [0,0,0,0,0,0]
# Остаток
if ((block * numbers * bonus) — (damage1 * numbers1 * bonus1)) / block ⇐ 0:
ost = 0
else:
ost = ((block * numbers * bonus) — (damage1 * numbers1 * bonus1)) / block
# раненные
if ((block * numbers * bonus) — (damage1 * numbers1 * bonus1)) / block ⇐ 0:
ran = numbers * 0.2
else:
ran = (numbers — ((block * numbers * bonus) — (damage1 * numbers1 * bonus1)) / block) * 0.2
# потери
if ((block * numbers * bonus) — (damage1 * numbers1 * bonus1)) / block ⇐ 0:
pot = numbers — numbers * 0.2
else:
pot = (numbers — (((block * numbers * bonus) — (damage1 * numbers1 * bonus1)) / block)) — (
(numbers — ((block * numbers * bonus) — (damage1 * numbers1 * bonus1)) / block) * 0.2)
# Остаток
if ((block1 * numbers1 * bonus1) — (damage * numbers * bonus)) / block1 ⇐ 0:
ost1 = 0
else:
ost1 = ((block1 * numbers1 * bonus1) — (damage * numbers * bonus)) / block1
# раненные
if ((block1 * numbers1 * bonus1) — (damage * numbers * bonus)) / block1 ⇐ 0:
ran1 = numbers1 * 0.2
else:
ran1 = (numbers1 — ((block1 * numbers1 * bonus1) — (damage * numbers * bonus)) / block1) * 0.2
# потери
if ((block1 * numbers1 * bonus1) — (damage * numbers * bonus)) / block1 ⇐ 0:
pot1 = numbers1 — numbers * 0.2
else:
pot1 = (numbers1 — (((block1 * numbers1 * bonus1) — (damage * numbers * bonus)) / block1)) — (
(numbers1 — ((block1 * numbers1 * bonus1) — (damage * numbers * bonus)) / block1) * 0.2)
helper[0] = ost
helper[1] = ran
helper[2] = pot
helper[3] = ost1
helper[4] = ran1
helper[5] = pot1
return helper
def b2_click(static):
a = str(static[0])
a2 = str(static[1])
a3 = str(static[2])
a4 = str(static[3])
a5 = str(static[4])
a6 = str(static[5])
frame6 = Frame(root, bg=«red»)
frame6.place(relx=0.1, rely=0.5, relheight=0.2, relwidth=0.2)
poter = Label(frame6, text="Потери "+a, bg='black', fg='white')
poter.pack()
ran = Label(frame6, text='раненные '+a2, bg='black', fg='white')
ran.pack()
ost = Label(frame6, text='остаток '+a3, bg='black', fg='white')
ost.pack()
frame8 = Frame(root, bg=«red»)
frame8.place(relx=0.6, rely=0.5, relheight=0.2, relwidth=0.2)
poter1 = Label(frame8, text="Потери "+a4, bg='black', fg='white')
poter1.pack()
ran1 = Label(frame8, text='раненные '+a5, bg='black', fg='white')
ran1.pack()
ost1 = Label(frame8, text='остаток '+a6, bg='black', fg='white')
ost1.pack()
return
root.geometry('500x500')
root.title('Kalkulator')
canvas = Canvas(root, width=500, height=500)
canvas.pack()
frame = Frame(root, bg='red')
frame.place(relx=0.75, rely=0.75, relheight=0.15, relwidth=0.15)
frame2 = Frame(root, bg='red')
frame2.place(relx=0.1, rely=0.05, relheight=0.20, relwidth=0.20)
damage = Label(frame2, text='Атака', bg='black', fg='white' )
damage.pack()
block = Label(frame2, text='Защита', bg='black', fg='white' )
block.pack()
numbers = Label(frame2, text='Количество', bg='black', fg='white' )
numbers.pack()
bonus = Label(frame2, text='Бонус', bg='black', fg='white')
bonus.pack()
frame3 = Frame(root, bg='green')
frame3.place(relx=0.30, rely=0.05, relheight=0.20, relwidth=0.15)
loginput = Entry(frame3, bg='black', fg='white')
loginput.pack()
loginput2 = Entry(frame3, bg='black', fg='white')
loginput2.pack()
loginput3 = Entry(frame3, bg='black', fg='white')
loginput3.pack()
loginput4 = Entry(frame3, bg='black', fg='white')
loginput4.pack()
frame4 = Frame(root, bg='purple')
frame4.place(relx=0.55, rely=0.05, relheight=0.20, relwidth=0.20)
damage1 = Label(frame4, text='Атака', bg='black', fg='white')
damage1.pack()
block1 = Label(frame4, text='Защита', bg='black', fg='white')
block1.pack()
numbers1 = Label(frame4, text='Количество', bg='black', fg='white')
numbers1.pack()
bonus1 = Label(frame4, text='Бонус', bg='black', fg='white')
bonus1.pack()
frame5 = Frame(root, bg='green')
frame5.place(relx=0.75, rely=0.05, relheight=0.20, relwidth=0.15)
loginput5 = Entry(frame5, bg='black', fg='white')
loginput5.pack()
loginput6 = Entry(frame5, bg='black', fg='white')
loginput6.pack()
loginput7 = Entry(frame5, bg='black', fg='white')
loginput7.pack()
loginput8 = Entry(frame5, bg='black', fg='white')
loginput8.pack()
perem = int(loginput.get()+'1')
perem1 = int(loginput2.get()+'1')
perem2 = int(loginput3.get()+'1')
perem3 = int(loginput4.get()+'1')
perem4 = int(loginput5.get()+'1')
perem5 = int(loginput6.get()+'1')
perem6 = int(loginput7.get()+'1')
perem7 = int(loginput8.get()+'1')
static = b3_cal(perem,perem1,perem2,perem3,perem4,perem5,perem6,perem7)
b1 = Button(frame, text='generate', bg='yellow', command = b2_click(static))
b1.pack()