0

ValueError? How to fix it?

#from tkinter import * import tkinter import tkinter as tk import math import tkinter.messagebox #Create a Tk window window=tk.Tk() #window.geometry, sit window as 500*600 window.Tk=("600x600") #Window Title window.title("BMI calculater") title=tk.Label(window, text="BMI calculater", font=("Sim Hei", 22)) #peast the text that I want, set the pady=18 title.pack(pady=12) #main body part, set main title_1 #Weight main_title1=tk.Label(window, text="Please enter your weight using kg or pound in first textbox: ",font=("Sim Hei", 18)) main_title1.pack(pady=10) #Set the entry textbox below,allowed the user import their weight text_box1=tk.Entry(window, font=("Sim Hei",15)) text_box1.pack(pady=8) #Height #Set the main_title 2 for height main_title2=tk.Label(window, text="And your height use cm in second textbox : ",font=("Sim Hei", 18)) main_title2.pack(pady=10) #Set the entry textbox below,allowed the user import their weight text_box2=tk.Entry(window, font=("Sim Hei",15)) text_box2.pack(pady=8) #Create another button called Calculate enter=tk.Button(window, text="Calculate!",font=("Sim Hei",18)) enter.pack(pady=10) #Start calclute the BMI #Get the weight data def the_result(): weight=float(text_box1.get()) height=float(text_box2.get()) result=weight/height**2 round(result) if result<25: tkinter.messagebox.showinfo("Your BMI result","Your MBI value is normal"+str(result)) if result>=25: tkinter.messagebox.showwarning(" Your BMI is overweight, be careful"+str(result)) else: tkinter.messagebox.showerror("please enter a valid value ! only number allowed! "+str(result)) the_result()

27th Sep 2023, 2:03 AM
Andy birder
Andy birder - avatar
1 ответ
+ 1
Unfortunately, Sololearn doesn't support the module tkinter.
27th Sep 2023, 5:46 AM
Aaron Lee
Aaron Lee - avatar