import tkinter
tk=tkinter.Tk()
#设置窗口标题
tk.title("煤工业分析计算器")
#设置窗口大小
tk.geometry("565x220")
FC=tkinter.StringVar()
Qnet_ad=tkinter.StringVar()
Ad=tkinter.StringVar()
Vadf=tkinter.StringVar()
Vadfj=tkinter.StringVar()
K=tkinter.StringVar()
Jj=tkinter.StringVar()
#添加Label
label_Mad = tkinter.Label(tk,text="Mad")
label_Mad.place(x=10,y=10,width=50,height=25)
label_Aad = tkinter.Label(tk,text="Aad")
label_Aad.place(x=65,y=10,width=50,height=25)
label_Vad=tkinter.Label(tk,text="Vad")
label_Vad.place(x=120,y=10,width=50,height=25)
label_FC=tkinter.Label(tk,text="FC")
label_FC.place(x=175,y=10,width=50,height=25)
label_Qnet_ad=tkinter.Label(tk,text="Qnet.ad")
label_Qnet_ad.place(x=230,y=10,width=50,height=25)
label_Ad = tkinter.Label(tk,text="Ad")
label_Ad.place(x=285,y=10,width=50,height=25)
label_Vadf = tkinter.Label(tk,text="Vadf")
label_Vadf.place(x=340,y=10,width=50,height=25)
label_Vadfj = tkinter.Label(tk,text="Vadf校")
label_Vadfj.place(x=395,y=10,width=50,height=25)
label_K = tkinter.Label(tk,text="K")
label_K.place(x=450,y=10,width=50,height=25)
label_Jj = tkinter.Label(tk,text="焦渣特征")
label_Jj.place(x=505,y=10,width=50,height=25)
entry_Mad=tkinter.Entry(tk,textvariable=tkinter.StringVar())
entry_Mad.place(x=10,y=35,width=50,height=25)
entry_Aad=tkinter.Entry(tk,textvariable=tkinter.StringVar())
entry_Aad.place(x=65,y=35,width=50,height=25)
entry_Vad=tkinter.Entry(tk,textvariable=tkinter.StringVar())
entry_Vad.place(x=120,y=35,width=50,height=25)
entry_FC=tkinter.Entry(tk,textvariable=FC, state='readonly')
entry_FC.place(x=175,y=35,width=50,height=25)
entry_Qnet_ad=tkinter.Entry(tk,textvariable=Qnet_ad, state='readonly')
entry_Qnet_ad.place(x=230,y=35,width=50,height=25)
entry_Ad=tkinter.Entry(tk,textvariable=Ad,state='readonly')
entry_Ad.place(x=285,y=35,width=50,height=25)
entry_Vadf=tkinter.Entry(tk,textvariable=Vadf, state='readonly')
entry_Vadf.place(x=340,y=35,width=50,height=25)
entry_Vadfj=tkinter.Entry(tk,textvariable=Vadfj, state='readonly')
entry_Vadfj.place(x=395,y=35,width=50,height=25)
entry_K=tkinter.Entry(tk,textvariable=K, state='readonly')
entry_K.place(x=450,y=35,width=50,height=25)
entry_Jj=tkinter.Entry(tk,textvariable=Jj)
entry_Jj.place(x=505,y=35,width=50,height=25)
def aq():
fc = round(100-float(entry_Mad.get())-float(entry_Aad.get())-float(entry_Vad.get()),2)
FC.set(fc)
ad = round(float(entry_Aad.get())*100/(100-float(entry_Mad.get())),4)
Ad.set(ad)
vadf = round(float(entry_Vad.get())*100/(100-(float(entry_Mad.get())+float(entry_Aad.get()))),4)
Vadf.set(vadf)
if float(ad)<=10:
if float(ad)<10:
vadfj=round(0.95*vadf,4)
elif float(ad)>=10 and float(ad)<15:
vadfj=round(0.9*vadf,4)
elif float(ad)>=15 and float(ad)<20:
vadfj=round(0.8*vadf,4)
elif float(ad)>=20 and float(ad)<25:
vadfj=round((0.95*vadf-0.1*ad),4)
elif float(ad)>=25 and float(ad)<30:
vadfj=round((0.85*vadf-0.1*ad),4)
elif float(ad)>=30 and float(ad)<40:
vadfj=round((0.8*vadf-0.1*ad),4)
Vadfj.set(vadfj)
if float(entry_Vad.get())<=10: #无烟煤计算
if float(vadfj)<=3:
k=8200
elif float(vadfj)<=5.5 and float(vadfj)>3:
k=8300
elif float(vadfj)<=8 and float(vadfj)>5.5:
k=8400
elif float(vadfj)<=10 and float(vadfj)>8.0:
k=8500
K.set(k)
qnetad = round((k-86*float(entry_Mad.get())-92*float(entry_Aad.get())-24*float(entry_Vad.get())),0)
Qnet_ad.set(qnetad)
if float(entry_Vad.get())>10.0: #烟煤计算
if float(vadfj)>10 and float(vadfj)<=13.5: #Vadf校正在10-13.5范围内K的选择
if float(entry_Jj.get())>=1 and float(entry_Jj.get())<=2:
k=84
elif float(entry_Jj.get())>=3 and float(entry_Jj.get())<=7:
k=84.5
if float(vadfj)>13.5 and float(vadfj)<=17: #Vadf校正在13.5-17范围内K的选择
if float(entry_Jj.get())==1:
k=80.5
elif float(entry_Jj.get())==2:
k=83.5
elif float(entry_Jj.get())==3:
k=84.5
elif float(entry_Jj.get())>=4 and float(entry_Jj.get())<=8:
k=85
if float(vadfj)>17 and float(vadfj)<=20: #Vadf校正在17-20范围内K的选择
if float(entry_Jj.get())==1:
k=80
elif float(entry_Jj.get())==2:
k=82
elif float(entry_Jj.get())==3:
k=83.5
elif float(entry_Jj.get())==4:
k=84
elif float(entry_Jj.get())>=5 and float(entry_Jj.get())<=8:
k=85
if float(vadfj)>20 and float(vadfj)<=23: #Vadf校正在20-23范围内K的选择
if float(entry_Jj.get())==1:
k=78.5
elif float(entry_Jj.get())==2:
k=81
elif float(entry_Jj.get())==3:
k=82.5
elif float(entry_Jj.get())==4:
k=83
elif float(entry_Jj.get())==5:
k=84
elif float(entry_Jj.get())==6:
k=84
elif float(entry_Jj.get())==7:
k=85
elif float(entry_Jj.get())==8:
k=85.5
if float(vadfj)>23 and float(vadfj)<=29: #Vadf校正在23-29范围内K的选择
if float(entry_Jj.get())==1:
k=76.5
elif float(entry_Jj.get())==2:
k=78
elif float(entry_Jj.get())==3:
k=81
elif float(entry_Jj.get())==4:
k=82
elif float(entry_Jj.get())==5:
k=83.5
elif float(entry_Jj.get())==6:
k=83.5
elif float(entry_Jj.get())==7:
k=84.5
elif float(entry_Jj.get())==8:
k=85
if float(vadfj)>29 and float(vadfj)<=32: #Vadf校正在23-29范围内K的选择
if float(entry_Jj.get())==1:
k=76.5
elif float(entry_Jj.get())==2:
k=78
elif float(entry_Jj.get())==3:
k=80
elif float(entry_Jj.get())==4:
k=81
elif float(entry_Jj.get())==5:
k=82.5
elif float(entry_Jj.get())==6:
k=82.5
elif float(entry_Jj.get())==7:
k=84
elif float(entry_Jj.get())==8:
k=84.5
if float(vadfj)>29 and float(vadfj)<=32: #Vadf校正在32-35范围内K的选择
if float(entry_Jj.get())==1:
k=73
elif float(entry_Jj.get())==2:
k=77.5
elif float(entry_Jj.get())==3:
k=79
elif float(entry_Jj.get())==4:
k=80
elif float(entry_Jj.get())==5:
k=81.5
elif float(entry_Jj.get())==6:
k=81.5
elif float(entry_Jj.get())==7:
k=83
elif float(entry_Jj.get())==8:
k=83.5
if float(vadfj)>35 and float(vadfj)<=38: #Vadf校正在32-35范围内K的选择
if float(entry_Jj.get())==1:
k=73
elif float(entry_Jj.get())==2:
k=76.5
elif float(entry_Jj.get())==3:
k=78.5
elif float(entry_Jj.get())==4:
k=79.5
elif float(entry_Jj.get())==5:
k=81
elif float(entry_Jj.get())==6:
k=81
elif float(entry_Jj.get())==7:
k=82.5
elif float(entry_Jj.get())==8:
k=83
if float(vadfj)>38 and float(vadfj)<=42: #Vadf校正在38-42范围内K的选择
if float(entry_Jj.get())==1:
k=73
elif float(entry_Jj.get())==2:
k=75.5
elif float(entry_Jj.get())==3:
k=78
elif float(entry_Jj.get())==4:
k=79
elif float(entry_Jj.get())==5:
k=80
elif float(entry_Jj.get())==6:
k=80
elif float(entry_Jj.get())==7:
k=82
elif float(entry_Jj.get())==8:
k=82.5
if float(vadfj)>42: #Vadf校正大于42范围内K的选择
if float(entry_Jj.get())==1:
k=72.5
elif float(entry_Jj.get())==2:
k=74.5
elif float(entry_Jj.get())==3:
k=76.6
elif float(entry_Jj.get())==4:
k=77.5
elif float(entry_Jj.get())==5:
k=79.5
elif float(entry_Jj.get())==6:
k=79.5
elif float(entry_Jj.get())==7:
k=81
elif float(entry_Jj.get())==8:
k=82
qnetad = round((100*k-(k+6)*(float(entry_Mad.get())+float(entry_Aad.get()))-3*float(entry_Vad.get())),0)
Qnet_ad.set(qnetad)
b1=tkinter.Button(tk,text="结果",command=aq)
b1.place(x=189,y=90,width=200,height=100)
tk.mainloop()