(提醒⚠️:不喜勿喷!信息来源书本与网络,若有侵权,请私聊作者,本人会删除此文章!
若要调用,请与我联系!)
1,源码:
#导入tkinter库
from tkinter import *
#摄氏度转华氏度函数体
def SZH():
def btnClicked1():
cd1 = float(entryCd1.get())
label1.config(text = "%.3f°C = %.3f°F" % (cd1,cd1 * 1.8 + 32))
def close_VICE_SZH():
VICE1_root.destroy()
VICE1_root = Tk(className = '摄氏度°C转华氏度°F')
VICE1_root.geometry("350x300+0+0")
close_button_VICE_SZH = Button(VICE1_root,text = "返回主界面",height=1,width=15,fg = 'red',command = close_VICE_SZH)
label1 = Label(VICE1_root,text = "摄氏度°C转华氏度°F",height = 5,width = 350,fg = "blue")
entryCd1 = Entry(VICE1_root,text = "0")
btnCal = Button(VICE1_root,text = "转换",command = btnClicked1)
label1.pack()
entryCd1.pack()
btnCal.pack()
close_button_VICE_SZH.pack()
VICE1_root.mainloop()
#华氏度转摄氏度函数体
def HZS():
def btnClicked2():
cd2 = float(entryCd2.get())
label2.config(text = "%.3f°C = %.3f°F" % (cd2,(cd2 - 32)/1.8))
def close_VICE_HZS():
VICE2_root.destroy()
VICE2_root = Tk(className = '华氏度°F转摄氏度°C')
VICE2_root.geometry("350x300+0+0")
close_button_VICE_HZS = Button(VICE2_root,text = "返回主界面",height=1,width=15,fg = 'red',command = close_VICE_HZS)
label2 = Label(VICE2_root,text = "华氏度°F转摄氏度°C",height = 5,width = 350,fg = "blue")
entryCd2 = Entry(VICE2_root,text = "0")
btnCal2 = Button(VICE2_root,text = "转换",command = btnClicked2)
label2.pack()
entryCd2.pack()
btnCal2.pack()
close_button_VICE_HZS.pack()
VICE2_root.mainloop()
#热力学温度转摄氏度函数体
def KZS():
def btnClicked3():
cd3 = float(entryCd3.get())
label3.config(text = "%.3fK = %.3f°C" % (cd3,(cd3 - 273.15)))
def close_VICE_KZS():
VICE3_root.destroy()
VICE3_root = Tk(className = '热力学温度K转摄氏度°C')
VICE3_root.geometry("350x300+0+0")
close_button_VICE_KZS = Button(VICE3_root,text = "返回主界面",height=1,width=15,fg = 'red',command = close_VICE_KZS)
label3 = Label(VICE3_root,text = "热力学温度K转摄氏度°C",height = 5,width = 350,fg = "blue")
entryCd3 = Entry(VICE3_root,text = "0")
btnCal3 = Button(VICE3_root,text = "转换",command = btnClicked3)
label3.pack()
entryCd3.pack()
btnCal3.pack()
close_button_VICE_KZS.pack()
VICE3_root.mainloop()
#摄氏度转热力学温度函数体
def SZK():
def btnClicked4():
cd4 = float(entryCd4.get())
label4.config(text = "%.3f°C = %.3fK" % (cd4,(cd4 + 273.15)))
def close_VICE_SZK():
VICE4_root.destroy()
VICE4_root = Tk(className = '摄氏度°C转热力学温度K')
VICE4_root.geometry("350x300+0+0")
close_button_VICE_SZK = Button(VICE4_root,text = "返回主界面",height=1,width=15,fg = 'red',command = close_VICE_SZK)
label4 = Label(VICE4_root,text = "摄氏度°C转热力学温度K",height = 5,width = 350,fg = "blue")
entryCd4 = Entry(VICE4_root,text = "0")
btnCal4 = Button(VICE4_root,text = "转换",command = btnClicked4)
label4.pack()
entryCd4.pack()
btnCal4.pack()
close_button_VICE_SZK.pack()
VICE4_root.mainloop()
#热力学温度转华氏度函数体
def KZH():
def btnClicked5():
cd5 = float(entryCd5.get())
label5.config(text = "%.3fK = %.3f°F" % (cd5,((cd5-273.5)*1.8/5+32)))
def close_VICE_KZH():
VICE5_root.destroy()
VICE5_root = Tk(className = '热力学温度K转华氏度°F')
VICE5_root.geometry("350x300+0+0")
close_button_VICE_KZH = Button(VICE5_root,text = "返回主界面",height=1,width=15,fg = 'red',command = close_VICE_KZH)
label5 = Label(VICE5_root,text = "热力学温度K转华氏度°F",height = 5,width = 350,fg = "blue")
entryCd5 = Entry(VICE5_root,text = "0")
btnCal5 = Button(VICE5_root,text = "转换",command = btnClicked5)
label5.pack()
entryCd5.pack()
btnCal5.pack()
close_button_VICE_KZH.pack()
VICE5_root.mainloop()
#华氏度转热力学温度函数体
def HZK():
def btnClicked6():
cd6 = float(entryCd6.get())
label6.config(text = "%.3f°F = %.3fK" % (cd6,((cd6-32)*5/1.8+273.5)))
def close_VICE_HZK():
VICE6_root.destroy()
VICE6_root = Tk(className = '华氏度°F转热力学温度K')
VICE6_root.geometry("350x300+0+0")
close_button_VICE_HZK = Button(VICE6_root,text = "返回主界面",height=1,width=15,fg = 'red',command = close_VICE_HZK)
label6 = Label(VICE6_root,text = "华氏度°F转热力学温度K",height = 5,width = 350,fg = "blue")
entryCd6 = Entry(VICE6_root,text = "0")
btnCal6 = Button(VICE6_root,text = "转换",command = btnClicked6)
label6.pack()
entryCd6.pack()
btnCal6.pack()
close_button_VICE_HZK.pack()
VICE6_root.mainloop()
#主界面关闭函数体
def close_HOST():
root.destroy()
root = Tk(className = '温度互转仪')
root.geometry("350x350+100+100")
root.overrideredirect(True)
l = Label(root,text = "转换模式",height=2,width=20,fg="orange")
close_button_HOST = Button(root,text = "×",height=1,width=5,font=("微软雅黑",15),fg = 'black',bd=0,command = close_HOST)
button1 = Button(root,text = "摄氏度°C转华氏度°F",height=1,width=30,fg = 'red',command = SZH)
button2 = Button(root,text = "华氏度°F转摄氏度°C",height=1,width=30,fg = 'red',command = HZS)
button3 = Button(root,text = "热力学温度K转摄氏度°C",height=1,width=30,fg = 'red',command = KZS)
button4 = Button(root,text = "摄氏度°C转热力学温度K",height=1,width=30,fg = 'red',command = SZK)
button5 = Button(root,text = "热力学温度K转华氏度°F",height=1,width=30,fg = 'red',command = KZH)
button6 = Button(root,text = "华氏度°F转热力学温度K",height=1,width=30,fg = 'red',command = HZK)
close_button_HOST.place(x=300,y=0)
l.pack()
button1.pack()
button2.pack()
button3.pack()
button4.pack()
button5.pack()
button6.pack()
root.mainloop()