欢迎光临散文网 会员登陆 & 注册

from tkinter import * a=Tk() a.title('BMI计算') a.geometry('400x40

2023-04-18 14:57 作者:Xiaonap  | 我要投稿

from tkinter import *

a=Tk()

a.title('BMI计算')

a.geometry('400x400')


L1=Label(a,text="身高(m):")

L2=Label(a,text="体重(kg):")

L1.grid(row=0, column=0)

L2.grid(row=1, column=0)


H=Entry(a,width=30)

H.grid(row=0, column=1)

W=Entry(a,width=30)

W.grid(row=1, column=1)


L3=Label(a,text='')

L4=Label(a,text='')

L3.grid(row=2,column=1)

L4.grid(row=3,column=1)


def u():

    m=float(H.get())

    n=float(W.get())

    s=n/m**2

    L3.config(text=str(s))

    if s<18.5:

        L4.config(text='体重过轻')

    elif s>=18.5 and s<24.9:

        L4.config(text='正常范围')

    elif s>=24.9 and s<29.9:

        L4.config(text='体重过重')

    else :

        L4.config(text='肥胖')


J=Button(a,text='计算',command=u)

J.grid(row=4, column=1)


mainloop()


from tkinter import * a=Tk() a.title('BMI计算') a.geometry('400x40的评论 (共 条)

分享到微博请遵守国家法律