import tkinter
from tkinter import *
def msgbox():
class BMI:
def __init__(self,name, age, weight, height):
self.name = name
self.age = age
self.weight = weight
self.height = height
self.bmi = self.weight / (self.height*self.height)
def get_name(self):
#print(self.name)
return self.name
def get_bmi(self):
return self.bmi
def get_status(self):
if self.bmi < 18.5:
self.status = "偏廋"
else:
self.status = "正常"
return self.status
root = Tk()
root.title("健康测试")
Label(root,text="姓名:").grid(row = 0,column =0)
Label(root,text="年龄:").grid(row = 1,column =0)
Label(root,text="身高:").grid(row = 2,column =0)
Label(root,text="体重:").grid(row = 3,column =0)
Label(root,text="结果:").grid(row = 4,column =0)
e1 = Entry(root)
e2 = Entry(root)
e3 = Entry(root)
e4 = Entry(root)
e5 = Entry(root)
e1.grid(row =0 ,column =1)
e2.grid(row =1 ,column =1)
e3.grid(row =2 ,column =1)
e4.grid(row =3 ,column =1)
e5.grid(row =4 ,column =1)
theButton1 = Button(root, text ="计算BMI", width =10,command =msgbox)
theButton1.grid(row =6 ,column =0,sticky =W, padx=10,pady =5)
mainloop()
2020-12-10
最新推荐文章于 2021-02-05 21:50:27 发布