Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from tkinter import *
- soft = Tk()
- soft.title("Doi tien v2.0")
- # exe
- def main():
- # get data
- mo1 = tien1.get()
- mo2 = tien2.get()
- soGia = text1.get()
- f = open('list.txt')
- data = dict()
- for line in f:
- c = line.split(',')
- for thing in c:
- lis = thing.split(':')
- data[lis[0]] = lis[1]
- print(data)
- # exchange
- giatri = float(soGia) * float(data[mo1])/float(data[mo2])
- giatri = round(giatri,2)
- out.delete(0.0, END)
- out.insert(END, giatri)
- # Add a grid
- mainframe = Frame(soft)
- mainframe.grid(column=0, row=0, sticky=(N, W, E, S))
- mainframe.columnconfigure(0, weight=1)
- mainframe.rowconfigure(0, weight=1)
- # Create a Tkinter variable
- tien1 = StringVar(soft)
- tien2 = StringVar(soft)
- # Dictionary with options
- listTien1 = {'Dollar_US', 'Pound', 'SG_dollar', 'Baht', 'Yen', 'Yuan', 'VND', 'Won', 'Euro', 'Rub'}
- tien1.set('Dollar_US')
- listTien2 = {'Dollar_US', 'Pound', 'SG_dollar', 'Baht', 'Yen', 'Yuan', 'VND', 'Won', 'Euro', 'Rub'}
- tien2.set('Dollar_US')
- popupMenu = OptionMenu(mainframe, tien1, *listTien1)
- Label(mainframe, text="Choose currency 1:").grid(row=1, column=1)
- text1 = Entry(soft, width = 30, bg ="white")
- text1.grid(row=2,column=0, sticky = N)
- popupMenu.grid(row=4, column=1)
- out = Text(soft, width = 10, height = 2, background="white")
- out.grid(row=12, column=0, sticky=N)
- popupMenu2 = OptionMenu(mainframe, tien2, *listTien2)
- Label(mainframe, text="Choose currency 2:").grid(row=5, column=1)
- # text2 = Entry(soft, width = 30, bg ="white")
- # text2.grid(row=6,column=0, sticky = N)
- popupMenu2.grid(row=7, column=1)
- Label(mainframe, text="Nhap so don vi:").grid(row=10, column=1)
- Button(soft, text = "Exchange!", width =10, command = main).grid(row = 9, column = 0, sticky = N)
- soft.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement