我是编程初学者,所以如果代码混乱或太长,我很抱歉。我的问题是:我被费率输入以及如何将所有内容放在一起以使转换有效?
谢谢你。
from tkinter import *
def convertDtoE():
fromDtoE=fromDtoEVar
fromDtoEVar.get()
fromEtoD=fromEtoDVar
fromEtoDVar.get()
fromDtoEVar.set(fromEtoD)
def convertEtoD():
fromDtoE=fromDtoEVar
fromDtoEVar.get()
fromEtoD=fromEtoDVar
fromEtoDVar.get()
fromEtoDVar.set(fromDtoE)
def main():
window=Tk()
global fromDtoEVar
fromDtoEVar=DoubleVar()
fromDtoEVar.set(0.0)
global fromEtoDVar
fromEtoDVar=DoubleVar()
fromEtoDVar.set(0.0)
aa=Label(window,text="Dollars")
aa.pack()
a=Entry(window,textvariable=fromDtoEVar)
a.pack()
rr=Label(window,text="Rate")
rr.pack()
rate=Entry(window)
rate.pack()
bb=Label(window,text="Euros")
bb.pack()
b=Entry(window,textvariable=fromEtoDVar)
b.pack()
c=Button(window, text="Convert Euros", command=convertEtoD)
c.pack()
d=Button(window, text="Convert Dollars", command=convertDtoE)
d.pack()
window.mainloop()
main()