0
我的代碼是爲了獲取用戶輸入的金額修復邏輯錯誤,然後乘以在下拉菜單中進行了選擇的價值的字典選項。但是,它會將轉換率打印爲用戶輸入的次數。你能幫我在我的代碼在那裏打印的值的時間,而不是產品
from tkinter import * #Imports everything from the tkinter module
#Imports everything from the math module
wall = Tk() #Creates the window
wall.title('CC V2.1.1.2') #Labels the window with the version number
var = StringVar(wall)
global ConR
ConR = 0
options = {
'AU': '1',
'US': '.77',
'EU': '.55',
'Yen': '.011',
'NZ': '1.25',
}
option = OptionMenu(wall, var, *options)#Conversion Rate, default is one (the value that you entered)
var.set('AU')
option.pack()
def evaluate(event):
ConR = options[var.get()]
print (ConR)
res.configure(text = "Converted value: $" + (str(eval(entry.get()*ConR))))#Takes the value entered from entry.bind and multiplies it by the currency chosen by the user, and prints it at the bottom of the window
entry = Entry(wall) #Creates the entry widgit
entry.bind("<Return>", evaluate)
entry.pack()
res = Label(wall)
res.pack()
y = Button(text='Quit', command=quit)#An exit button
y.pack()
wall.mainloop()
太謝謝你了!如果你有一個reddit賬戶,你可以把它鏈接到我,我可以給你黃金嗎?你不知道我有多愛你。 –
其優良的我只是很高興在這裏代表點:),我想諮詢您接受通過點擊答案左側的刻度標記的答案,這將是有幫助的社區。我很高興我可以幫助:)。 –