나는 초보자 프로그래머이며 화폐 변환기를 만들고 있습니다 .... 아직 진행 중이지만 'def convert()'레이블을 바꾸려는 사람이 도와 주실 수 있습니다 ... 분명히하려면,Tkinter python의 라벨을 어떻게 대체합니까?
이혼란스러워 제발 도와주세요 : 지금 내가 변환 할 때마다,
이import sys
from Tkinter import *
root = Tk()
root.title("CURRENCY CONVERTER")
root.geometry('600x300+30+100')
root.config(bg="#000000")
#*************************************GBP*************************************#
def rate():
rate = 1
if var.get() =='GBP' and var2.get() =='USD':
rate=float(1.63452)
if var.get() =='GBP' and var2.get() =='EUR':
rate=float(1.19529)
if var.get() =='GBP' and var2.get() =='INR':
rate=float(99.9639)
if var.get() =='GBP' and var2.get() =='AUD':
rate=float(1.79578)
if var.get() =='GBP' and var2.get() =='CAD':
rate=float(16.8796)
if var.get() =='GBP' and var2.get() =='NZD':
rate=float(1.97334)
if var.get() =='GBP' and var2.get() =='JPY':
rate=float(168.143)
if var.get() =='GBP' and var2.get() =='CNY':
rate=float(9.93698)
#*************************************USD*************************************#
if var.get() =='USD' and var2.get() =='GBP':
rate=float()
##to do ....ADD MORE
return rate
#----------------------------------HELP------------------------------#
def convert():
converted=Label(root, text=(var.get(), int(entarr.get()),">>>", round((float(entarr.get())*rate()),3), var2.get()))
converted.config(font=('century gothic',(15)),bg='#000000',fg="white",width=0, relief=FLAT)
converted.pack(expand = 1,anchor="center")
return
#--------------------------------HELP--------------------------------#
#title
Title=Label(root, text="Currency Converter", cursor="heart")
Title.config(font=('century gothic',(35)),bg='#fff60b', fg="#9c0200",width=0,relief=RAISED)
Title.pack(expand=1, anchor=CENTER)
#entry box
entarr = DoubleVar()
entarr.set(0)
entry = Entry(root, textvariable=entarr, cursor="plus")
entry.config(font=('century gothic',(15)),bg='#ff6100',width=0, relief=SOLID)
entry.pack(expand = 1, anchor="center")
#currency 1
var = StringVar(root)
var.set('Choose a currency to convert from')
choices = ['GBP', 'USD', 'EUR','INR','AUD','CAD','NZD','JPY','CNY']
option = OptionMenu(root, var, *choices)
option.config(font=('century gothic',(15)),bg='#fff60b',fg="#9c0200",activebackground='#00ff80',width=0, cursor="", relief=FLAT)
option.pack(ipadx=10,ipady=0, expand=1,anchor="center")
#convert button
Arrow= Button(root, text=">>>>CONVERT>>>>", command = convert, cursor="exchange")
Arrow.config(font=('century gothic',(15)),width=0, bg="#ff6100", relief=SOLID)
Arrow.pack(ipadx=1,ipady=0, expand =1, anchor="center")
#currency 2
var2 = StringVar(root)
var2.set('Choose a currency to convert to')
choices2 = ['GBP', 'USD', 'EUR','INR','AUD','CAD','NZD','JPY','CNY']
option2 = OptionMenu(root, var2, *choices2)
option2.config(font=('century gothic',(15)),bg='#fff60b',fg="#9c0200",activebackground='#00ff80',width=0, relief=FLAT)
option2.pack(ipadx=10,ipady=0, expand=1,anchor="center")
root.mainloop()
이 편집 ... 새 레이블은 아래 팝업,하지만 내가 일 할 내 레이블마다 나는 변환을 클릭 대체됩니다 있다는 것입니다 . 나는 전혀 모른다, 여기의 훌륭한 놈.
def convert():
newValue=(var.get(), int(entarr.get()),">>>", round((float(entarr.get())*rate()),3), var2.get())
converted=Label(root, textvariable=newValue)
converted.config(font=('century gothic',(15)),bg='#000000',fg="white",width=0, relief=FLAT)
converted.config(text=newValue)
converted.pack(expand = 1,anchor="center")
return
안녕하세요, 답변 해 주셔서 너무 감사드립니다 ...하지만 제가 말씀 드렸듯이, 나는 초보자입니다. 내 코드를 편집하여 내게 무슨 뜻인지 알려주시겠습니까? 다시 한 번 감사드립니다. –