Skip to content

Commit 118ddc9

Browse files
authored
Merge pull request larymak#103 from karthiks2611/main
Currency Converter
2 parents 9a83b42 + c46abf5 commit 118ddc9

File tree

4 files changed

+198
-0
lines changed

4 files changed

+198
-0
lines changed

Currency Converter/Background.jpg

190 KB
Loading

Currency Converter/Currency.py

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
from tkinter import *
2+
3+
from PIL import ImageTk, Image
4+
import tkinter.font as font
5+
6+
root = Tk()
7+
root.title("CURRENCY CONVERTER 2000")
8+
9+
root.minsize(1280,720)
10+
root.maxsize(1280,720)
11+
HEIGHT = 720
12+
WIDTH = 720
13+
FONT = font.Font(family="Open Sans",size="14", weight="bold")
14+
15+
canvas = Canvas(root, height=HEIGHT, width=WIDTH)
16+
canvas.pack()
17+
18+
background_image = ImageTk.PhotoImage(Image.open(r"Background.jpg"))
19+
background_label = Label(root,image=background_image)
20+
background_label.place(relwidth=1,relheight=1)
21+
22+
frame = Frame(root, bg="Red", bd=5)
23+
frame.place(relx=0.5, rely=0.1, relwidth=0.80,relheight=0.25, anchor="n")
24+
25+
label_up = Label(frame)
26+
label_up.place(relwidth=1, relheight=1)
27+
28+
lower_frame = Frame(root, bg="red", bd=10)
29+
lower_frame.place(relx=0.5,rely=0.53, relwidth=0.8, relheight=0.25, anchor="n")
30+
31+
label_down = Label(lower_frame,font=FONT, fg="#001a4d", anchor="nw",justify="left", bd=4)
32+
label_down.place(relwidth=1,relheight=1)
33+
34+
label1 = Label(frame,text = "FROM", font= FONT, bd=5,bg="#d9138a", highlightbackground = "#d9138a", fg="white")
35+
label1.place(relx=0.15, rely=0.02, relwidth = 0.15, relheight=0.25)
36+
37+
label2 = Label(frame, text = "TO", font =FONT, bd =5, bg ="#d9138a", highlightbackground = "#d9138a", fg = "white")
38+
label2.place(relx = 0.64,rely = 0.03,relwidth = 0.15, relheight =0.25)
39+
40+
#For Options menu
41+
options = [
42+
"BTC",
43+
"USD",
44+
"EUR",
45+
"INR",
46+
"GBP",
47+
"AUD",
48+
"CAD",
49+
"CHF",
50+
"RUB",
51+
"CNY",
52+
"JPY"
53+
]
54+
55+
clicked1 = StringVar()
56+
clicked1.set("Select")
57+
listbox1 = OptionMenu(frame, clicked1, *options)
58+
listbox1.config(bg="#fc034e", fg="black", activeforeground="#fc034e",activebackground="black", font=FONT)
59+
listbox1.place(relx=0.07,rely=0.03,relheight=0.28,relwidth=0.38)
60+
61+
clicked2 = StringVar()
62+
clicked2.set("Select")
63+
listbox2 = OptionMenu(frame,clicked2,*options)
64+
listbox2.config(bg="#fc034e", fg="black", activeforeground="#fc034e",activebackground="black", font=FONT)
65+
listbox2.place(relx=0.56,rely=0.3,relheight=0.28,relwidth=0.38)
66+
67+
#for logo image between two options list
68+
69+
label3 = Label(frame, text="AMOUNT", font=FONT, bg="#12a4d9",highlightbackground="#12a4d9",fg="white")
70+
label3.place(relx=0.26,rely=0.7,relwidth=0.26,relheight=0.25)
71+
72+
entry = Entry(frame,font=FONT,fg="#001a4d")
73+
entry.place(relx=0.54,rely=0.7,relwidth=0.26,relheight=0.25)
74+
75+
#buttons
76+
button1 = Button(root,text="CONVERT", font=FONT, bg="pink", fg="black", activeforeground="pink",activebackground="black")
77+
button1.place(relx=0.16,rely=0.4,relwidth=0.15,relheight=0.07)
78+
79+
button2 = Button(root, text = "CLEAR", font = FONT, bg = "pink", fg = "black", activeforeground = "pink", activebackground = "black")
80+
button2.place(relx = 0.35,rely = 0.4,relwidth = 0.13, relheight = 0.07)
81+
82+
button3 = Button(root, text = "REFERENCE", font = FONT, bg = "pink", fg = "black", activeforeground = "pink", activebackground = "black")
83+
button3.place(relx = 0.52, rely = 0.4, relwidth = 0.15, relheight = 0.07)
84+
85+
button4= Button(root, text = "EXIT", font = FONT, bg = "pink", fg = "black", activeforeground = "pink", activebackground = "black")
86+
button4.place(relx = 0.7, rely = 0.4, relwidth = 0.12, relheight = 0.07)
87+
88+
#-----------THE LOGIC---------------
89+
90+
from tkinter import messagebox
91+
from forex_python.converter import CurrencyRates
92+
from forex_python.bitcoin import BtcConverter
93+
94+
def clear():
95+
entry.delete(0,END)
96+
label_down["text"] = ""
97+
98+
99+
def convert(c1,c2,amount):
100+
try:
101+
if amount == "":
102+
messagebox.showerror("Error", "Amount not specified")
103+
elif c1 == "Select" or c2 == "Select":
104+
messagebox.showinfo("Error", "Currency not selected")
105+
else:
106+
try:
107+
amount = float(amount)
108+
b = BtcConverter()
109+
c = CurrencyRates()
110+
if c1 == c2:
111+
result = amount
112+
elif c1 == "BTC":
113+
result = b.convert_btc_to_cur(amount, c2)
114+
elif c2 == "BTC":
115+
result = b.convert_to_btc(amount, c1)
116+
else:
117+
result = c.convert(c1, c2, int(amount))
118+
print(result)
119+
label_down["text"] = f"Conversion Result: \n{amount} {c1} = {result} {c2}"
120+
except ValueError:
121+
messagebox.showerror("Error", "Invalid amount")
122+
clear()
123+
except Exception:
124+
messagebox.showerror("Error", "Something went wrong. Please try again")
125+
126+
def help():
127+
newwin = Tk()
128+
newwin.title("Reference")
129+
newwin.maxsize(400,300)
130+
newwin.minsize(400,300)
131+
newcanvas = Canvas(newwin, height = 400, width = 300)
132+
newcanvas.pack()
133+
newframe = Frame(newwin, bg ="yellow")
134+
newframe.place(relwidth = 1, relheight = 1)
135+
newlabel = Label(newframe, font = ("Comic Sans MS", 11, "bold"), fg ="#001a4d", anchor = "nw", justify = "left", bd =4)
136+
newlabel.place(relx = 0.05, rely = 0.05,relwidth = 0.90, relheight = 0.90)
137+
newlabel["text"] = "Abbrevations:\nBTC - Bitcoin\nUSD - USD Dollar\nEUR - Euro\nJPY - Japnese Yen\nGBP - Pound Sterling\nAUD - Australian Dollar\nCAD - Canadian Dollar\nCHF - Swiss Frank\nINR - Indian Rupees\nRUB - Russian Rubble\nCNY - Chinese Yuan"
138+
newbutton = Button(newframe, text = "Back",font = ("Comic Sans MS", 11, "bold"), bg = "pink", fg = "black", activeforeground = "pink", activebackground = "black", command = lambda:newwin.destroy())
139+
newbutton.place(relx = 0.76, rely = 0.82, relwidth = 0.14, relheight = 0.11)
140+
newwin.mainloop()
141+
142+
def exit():
143+
root.destroy()
144+
145+
146+
button1["command"] =lambda:convert(clicked1.get(), clicked2.get(), entry.get())
147+
button2["command"] = clear
148+
button3["command"] = help
149+
button4["command"] = exit
150+
151+
root.mainloop()

Currency Converter/README.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Currency Converter
2+
3+
This program takes one form of currency and converts into other form. The output value also changes depending on the current value in the market.
4+
5+
# Prerequisites
6+
7+
Make sure you have the following installed
8+
9+
```tkinter``` <br />
10+
```forex-python``` <br />
11+
```Pillow```
12+
13+
# To install them
14+
15+
```sudo apt-get install python-tk``` [For installing tkinter in Linux] <br />
16+
```pip3 install forex-python Pillow```
17+
18+
# To run this script
19+
```python Currency.py```
20+
21+
# DEMO
22+
Currency Conversion
23+
24+
25+
![image](https://raw.githubusercontent.com/skarthi2001/Images/main/Output.PNG)
26+
27+
28+
List types of currencies
29+
30+
31+
![image](https://raw.githubusercontent.com/skarthi2001/Images/main/Output2.PNG)
32+
33+
# Abbreviations
34+
35+
BTC - Bitcoin<br />
36+
USD - United States Dollar<br />
37+
EUR - Euro<br />
38+
INR - Indian Rupee<br />
39+
GBP - British Pound Sterling<br />
40+
AUD - Australian dollar<br />
41+
CAD - Canadian dollar<br />
42+
CHF - Swiss Franc<br />
43+
RUB - Russian Ruble<br />
44+
CNY - Chinese Yuan<br />
45+
JPY - Japanese Yen

Currency Converter/requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
forex_python==1.6
2+
Pillow==8.4.0

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy