daily pastebin goal
40%
SHARE
TWEET

Untitled

a guest Feb 20th, 2019 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from tkinter import *
  2. from tkinter import ttk
  3.  
  4. def clear():
  5.     e1.delete(0,END)
  6.     e3.delete(0,END)
  7.  
  8. def convert():
  9.     var2 = indicator.get()
  10.     var3 = var1.get()
  11.     if var2 == 'China':
  12.         e3.delete(0,END)
  13.         var4 = ((var3*6.88),'Yuan')
  14.         e3.insert(0,var4)
  15.     elif var2 == 'France':
  16.         e3.delete(0,END)
  17.         var4 = ((var3*0.81),'Euro')
  18.         e3.insert(0,var4)
  19.     elif var2 == 'Ghana':
  20.         e3.delete(0,END)
  21.         var4 = ((var3*4.88),'Cedi')
  22.         e3.insert(0,var4)
  23.     elif var2 == 'Mexico':
  24.         e3.delete(0,END)
  25.         var4 = ((var3*18.90),'MXN')
  26.         e3.insert(0,var4)
  27.     elif var2 == 'Nigeria':
  28.         e3.delete(0,END)
  29.         var4 = ((var3*360.01),'Naira')
  30.         e3.insert(0,var4)
  31.     elif var2 == 'USA':
  32.         e3.delete(0,END)
  33.         var4 = ((var3*1.00),'USD')
  34.         e3.insert(0,var4)
  35.     else:
  36.         e3.delete(0,END)
  37.         var4 = ('Error: Please, choose a country')
  38.         e3.insert(var4)
  39.  
  40.  
  41. root = Tk()
  42. root.title('Currency converter')
  43.  
  44. var1 = IntVar()
  45. indicator = StringVar(value='Choose a country')
  46.  
  47. Label(text='Currency Converter',padx=10,font=('arial', 16,'bold')).grid(row=0,column=1)
  48.  
  49. Label(text='Amount ($)',padx=10,font=('arial', 16,'bold')).grid(row=1,sticky=W)
  50. e1 = Entry(width=17,font=('arial', 16,'bold'), textvariable=var1)
  51. e1.grid(row=1,column=1)
  52.  
  53. Label(text='Country',padx=10,font=('arial', 16,'bold')).grid(row=2,sticky=W)
  54. e2 = ttk.Combobox(width=15,font=('arial', 16,'bold'),textvariable=indicator)
  55. e2['values'] = ('China', 'France', 'Ghana', 'Mexico', 'Nigeria', 'USA')
  56. e2.grid(row=2,column=1)
  57.  
  58. Label(text='Total',padx=10,font=('arial', 16,'bold'),fg='red').grid(row=3,sticky=W)
  59. e3 = Entry(width=17,font=('arial', 16,'bold'))
  60. e3.grid(row=3,column=1)
  61.  
  62. Button(text='Convert',font=('arial', 10,'bold'),width=12, command=convert).grid(row=4,column=1,sticky=W)
  63. Button(text='Clear',font=('arial', 10,'bold'),width=12, command=clear).grid(row=4,column=1,sticky=E)
  64.  
  65. root.mainloop()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top