So I'm very new to python and programming in general. I made this program who determines which person is heavier. Don't worry about why it's just a running gag between some friends. Anyways, I've been trying to put it into a GUI with Tkinter but am having issues with the entry boxes and converting them into integers. I've tried using IntVar, entry_box = int(entry_box), and entry_box = float(entry_box). Nothing seems to work and I'm getting errors every time.
from tkinter import *
root = Tk()
root.title("Who Is More Fat?")
root.geometry("640x640+0+0")
# LABELS
heading = Label(root, text="Welcome to the Who's More Fat Program", font=("arial", 40, "bold"),
fg="steelblue").pack()
person_1 = Label(root, text="Enter first persons name: ", font=("arial",20, "bold"),
fg="black").place(x=10, y=200)
weight_1 = Label(root, text="Enter first persons weight: ", font=("arial",20, "bold"),
fg="black").place(x=10, y=230)
person_2 = Label(root, text="Enter second persons name: ", font=("arial",20, "bold"),
fg="black").place(x=10, y=290)
weight_2 = Label(root, text="Enter second persons weight: ", font=("arial",20, "bold"),
fg="black").place(x=10, y=320)
# TEXT BOXES
entry_box1 = StringVar
entry_box2 = IntVar
entry_box3 = StringVar
entry_box4 = IntVar
entry_box1 = Entry(root, width=25, bg="white").place(x=350, y=210)
entry_box2 = Entry(root, width=25, bg="white").place(x=370, y=240)
entry_box3 = Entry(root, width=25, bg="white").place(x=395, y=300)
entry_box4 = Entry(root, width=25, bg="white").place(x=410, y=330)
entry_box1 = StringVar
entry_box2 = IntVar
entry_box3 = StringVar
entry_box4 = IntVar
def calc():
if entry_box2.get > entry_box4.get:
answer.insert(entry_box1.get)
answer.insert(" Is the Fattest")
else:
answer.insert(entry_box3.get)
answer.insert(" Is the Fattest")
# CALCULATE BUTTON
calculate = Button(root, text="Calculate the Fattest!", font=("arial",10, "bold"), bg="white",
command=calc).place(x=525, y=205)
answer = Label(root, text="Answer: ", font=("arial",10, "bold"), bg="white",).place(x=400, y=400)
Traceback
Tkinter callback Traceback (most recent call last):
FileC:\Users\Liam\AppData\Local\Programs\Python\Python37\lib\
tkinter_init_.py", line 1705, in call return self.func(*args)
File "C:/Users/Liam/PycharmProjects/untitled/window.py", line 30,
in calc if entry_box2.get > entry_box4.get:
AttributeError: 'NoneType' object has no attribute 'get' ```