This code was meant to calculate an hypothenuse value, but it isn't running, the application doesn't run it at all,I think the mistake is in the while
loops:
from math import *
import tkinter as tk
from tkinter import *
from tkinter import ttk
root = tk.Tk()
#USER choosen sizes:
wwdimensions = 300
whdimensions = 300
#Class to get screen dimensions easier
class winfo:
swidth = root.winfo_screenwidth()
sheight = root.winfo_screenheight()
def width(screenwidth,windowwidth):
intendedposwidth = int(screenwidth/2 - windowwidth/2)
return(intendedposwidth)
def height(screenheight,windowheight):
intendedposheight = int(screenheight/2 - windowheight/2)
return(intendedposheight)
screenwidth=winfo.swidth
screenheight = winfo.sheight
inputcenterw=winfo.width(screenwidth,wwdimensions)
inputcenterh=winfo.height(screenheight,whdimensions)
root.geometry("{}x{}+{}+{}".format(wwdimensions,whdimensions,inputcenterw,inputcenterh))
root.title("Pythagoream Theorem")
v1 = tk.StringVar()
v2 = tk.StringVar()
val1 = v1.get()
val2 = v2.get()
st = "disabled"
while val1 or val2 == "":
st = "disabled"
la=tk.Label(root,text="Fill the entry spaces").pack(fill=X,ipady=10,side= "bottom")
else:
st="disabled"
while val1 or val2 == str:
try:
val2 = float(val2)
val1 = float(val1)
except:
lab=tk.Label(root,text="Invalid dimensions,please solve it").pack(ipady=10,side="bottom",fill= X)
st = "disabled"
else:
st = "normal"
st = "normal"
def showmsg():
result = tk.Label(root, text = f"The hypotenuse is {sqrt(float(val1)**2+float(val2)**2)}",font=("Arial 12"))
result.pack(ipady=10,side="bottom",fill=X)
label1 = tk.Label(root,text="Insert the first side dimension").pack(fill=X,ipady=10)
entrybox1 = tk.Entry(root,font= ("Arial 12"),textvariable=v1).pack(fill=X,ipady=7)
label2 = tk.Label(root,text="Insert the second side dimension").pack(fill=X,ipady=10)
entrybox2 = tk.Entry(root,font=("Arial 12"),textvariable=v2).pack(fill=X,ipady=7)
button = tk.Button(root,font=("Arial 12"), command= showmsg,text="Done",state=st).pack(fill= "x")
root.mainloop()