Skip to content

Commit 9d7d727

Browse files
Add files via upload
1 parent 257a57d commit 9d7d727

3 files changed

Lines changed: 204 additions & 0 deletions

File tree

currency/currency-converter.py

Lines changed: 204 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,204 @@
1+
import tkinter as tk
2+
from tkinter import *
3+
from tkinter import ttk
4+
from datetime import datetime
5+
import requests
6+
from PIL import ImageTk, Image
7+
from tkinter import messagebox
8+
root = tk.Tk()
9+
root.geometry("600x270")
10+
root.title("Currency Converter")
11+
root.iconbitmap('icon.ico')
12+
root.maxsize(600,270)
13+
root.minsize(600,270)
14+
15+
16+
image = Image.open('currency.png')
17+
zoom = 0.5
18+
19+
#multiple image size by zoom
20+
pixels_x, pixels_y = tuple([int(zoom * x) for x in image.size])
21+
22+
img = ImageTk.PhotoImage(image.resize((pixels_x, pixels_y)))
23+
panel = Label(root, image = img)
24+
panel.place(x=190,y=35)
25+
26+
def show_data():
27+
amount = E1.get()
28+
from_currency = c1.get()
29+
to_currency = c2.get()
30+
url = 'http://api.currencylayer.com/live?access_key=4273d2c37f738367f08780b934ce7dda&format=1'
31+
32+
if amount == '':
33+
messagebox.showerror("Currency Converter", "Please Fill the Amount")
34+
elif to_currency == '':
35+
messagebox.showerror("Currency Converter", "Please Choose the Currency")
36+
37+
else:
38+
data = requests.get(url).json()
39+
currency = from_currency.strip()+to_currency.strip()
40+
amount = int(amount)
41+
cc = data['quotes'][currency]
42+
cur_conv = cc*amount
43+
E2.insert(0,cur_conv)
44+
45+
text.insert('end',f'{amount} United State Dollar Equals {cur_conv} {to_currency} \n\n Last Time Update --- \t {datetime.now()}')
46+
47+
def clear():
48+
E1.delete(0,'end')
49+
E2.delete(0,'end')
50+
text.delete(1.0,'end')
51+
52+
53+
l1 = Label(root,text="USD Currency Converter Using Python", font=('verdana','10','bold'))
54+
l1.place(x=150,y=15)
55+
56+
amt = Label(root,text="Amount",font=('roboto',10,'bold'))
57+
amt.place(x=20,y=15)
58+
E1 = Entry(root,width=20,borderwidth=1,font=('roboto',10,'bold'))
59+
E1.place(x=20,y=40)
60+
61+
c1 = tk.StringVar()
62+
c2 = tk.StringVar()
63+
currencychoose1 = ttk.Combobox(root, width = 20, textvariable = c1, state='readonly',font=('verdana',10,'bold'))
64+
65+
# Adding combobox drop down list
66+
currencychoose1['values'] = (
67+
' USD',
68+
)
69+
70+
currencychoose1.place(x=300,y=40)
71+
currencychoose1.current(0)
72+
73+
74+
75+
E2 = Entry(root,width=20,borderwidth=1,font=('roboto',10,'bold'))
76+
E2.place(x=20,y=80)
77+
78+
79+
currencychoose2 = ttk.Combobox(root, width = 20, textvariable = c2, state='readonly',font=('verdana','10','bold'))
80+
81+
# Adding combobox drop down list
82+
currencychoose2['values'] =('ALL',
83+
' AFN',
84+
' ARS',
85+
' AWG',
86+
' AUD',
87+
' AZN',
88+
' BSD',
89+
' BBD',
90+
' BYN',
91+
' BZD ',
92+
' BMD',
93+
' BOB',
94+
'BAM',
95+
' BWP',
96+
' BGN',
97+
' BND',
98+
' KHR',
99+
' CAD',
100+
' KYD',
101+
' CLP',
102+
' CNY',
103+
' COP ',
104+
' CRC',
105+
' HRK',
106+
'CUP',
107+
'CZK',
108+
' DKK',
109+
' DOP',
110+
' XCD',
111+
' EGP',
112+
' SVC',
113+
' EUR',
114+
' FKP',
115+
' FJD',
116+
' GHS ',
117+
' GIP',
118+
' GTQ',
119+
'GGP',
120+
' GYD',
121+
' HNL ',
122+
' HKD',
123+
' HUF',
124+
' ISK',
125+
' INR',
126+
' IDR',
127+
' IRR',
128+
' IMP ',
129+
' ILS',
130+
' JMD',
131+
'JPY',
132+
'KZT',
133+
' KPW',
134+
' KRW',
135+
' KGS',
136+
' LAK',
137+
' LBP',
138+
' LRD',
139+
' MKD',
140+
' MYR',
141+
' MUR ',
142+
' MXN',
143+
' MNT',
144+
'MZN',
145+
' NAD',
146+
' NPR',
147+
' ANG',
148+
' NZD ',
149+
' NIO ',
150+
' NGN',
151+
' NOK',
152+
' OMR ',
153+
' PKR ',
154+
' PAB',
155+
' PYG',
156+
'PEN',
157+
'PHP',
158+
' PLN',
159+
' QAR',
160+
' RON',
161+
' RUB',
162+
' SHP',
163+
' SAR',
164+
' RSD',
165+
' SCR ',
166+
' SGD ',
167+
' SBD',
168+
' SOS',
169+
'ZAR',
170+
' LKR',
171+
' SEK ',
172+
' CHF',
173+
' SRD',
174+
' SYP',
175+
' TWD',
176+
' THB',
177+
' TTD',
178+
' TRY ',
179+
' TVD',
180+
' UAH',
181+
'GBP ',
182+
' UYU',
183+
' UZS ',
184+
' VEF ',
185+
' VND',
186+
' YER',
187+
'ZWD',)
188+
189+
currencychoose2.place(x=300,y=80)
190+
currencychoose2.current()
191+
192+
193+
text = Text(root,height=7,width=52,font=('verdana','10','bold'))
194+
text.place(x=100,y=120)
195+
196+
B = Button(root,text="Search",command=show_data,font=('verdana','10','bold'),borderwidth=2,bg="red",fg="white")
197+
B.place(x=20,y=120)
198+
199+
clear = Button(root,text="Clear",command=clear,font=('verdana','10','bold'),borderwidth=2,bg="blue",fg="white")
200+
clear.place(x=20,y=170)
201+
202+
root.mainloop()
203+
204+
# <============ end code ==============>

currency/currency.png

8.54 KB
Loading

currency/icon.ico

18.5 KB
Binary file not shown.

0 commit comments

Comments
 (0)