0% found this document useful (0 votes)
89 views12 pages

Currency Transfigure

The document describes a currency conversion program created in Python. It uses the Tkinter GUI library and Requests library to retrieve live exchange rates and allow users to convert amounts between currencies. The program displays currency options in dropdown menus, accepts an input amount, retrieves the conversion rate from an API, and displays the result along with the last updated time. It provides a simple GUI for users to easily convert currencies in real-time.

Uploaded by

Ritthi S
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
89 views12 pages

Currency Transfigure

The document describes a currency conversion program created in Python. It uses the Tkinter GUI library and Requests library to retrieve live exchange rates and allow users to convert amounts between currencies. The program displays currency options in dropdown menus, accepts an input amount, retrieves the conversion rate from an API, and displays the result along with the last updated time. It provides a simple GUI for users to easily convert currencies in real-time.

Uploaded by

Ritthi S
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 12

CURRENCY TRANSFIGURE

INTORDUCTION:
The Currency Converter in Python is a simple project developed using python
3.6.8 version. This project is a GUI [Graphic User Interference] application
which converts Currency from one unit to another, for example: euros to
pounds, rupees to dollars, etc… Also, this app is capable of handling all types of
expectations of the business people. This project is an interesting as well as a
useful project.

OBJECTIVES OF CURRENCY TRANSFIGURE:

 It maintains real-time information on current market or bank exchange

rates so, that the calculated result changes whenever the value of either of

the component currencies does.

 They do so by connecting to a database of current currency exchange

rates.

 The frequency at which currency converts update the exchange rates they

use varies.

 Currency Transfigures usually display a value that is not biased towards

buying or selling.

 This is useful when estimating the value of goods or services, basic

accounting, invoicing and preparing financial plans and reports.


PREQUISTICS:

The Real Time Currency Converter using Python requires you to have basic


knowledge of python programming and the python game library.

 tkinter – For User Interface (UI)


 requests – to get url

#pip install tkinter


#pip install requests

Tkinter:
Tkinter is one of those great built-in Python libraries that has been around for a
long time; it is used to create snazzy graphical user interfaces (GUIs) for
desktop applications.
Requests library:
The requests library is the de facto standard for making HTTP requests in
Python. It abstracts the complexities of making requests behind a beautiful,
simple API so that you can focus on interacting with services and consuming
data in your application.

BASIC CODING FOR CURRENCY TRANSFIGURE:

# mkdir currencyconverter
# cd currencyconverter
# python -m venv env
# .\env\Scripts\activate.bat
# pip install requests

SOURCE CODE

# importing everything from tkinter


from tkinter import *
# importing ttk widgets from tkinter
from tkinter import ttk

import requests
#import json

# tkinter message box for displaying errors


from tkinter.messagebox import showerror

API_KEY = 'de66f6b06d4e3eee31a27a7c'

# the Standard request url


url = f'https://v6.exchangerate-api.com/v6/ de66f6b06d4e3eee31a27a7c
/latest/USD'

# making the Standard request to the API


response = requests.get(f'{url}').json()

# converting the currencies to dictionaries


currencies = dict(response['conversion_rates'])
def convert_currency():
# will execute the code when everything is ok
try:
# getting currency from first combobox
source = from_currency_combo.get()
# getting currency from second combobox
destination = to_currency_combo.get()
# getting amound from amount_entry
amount = amount_entry.get()
# sending a request to the Pair Conversion url and converting it to json
result = requests.get(f'https://v6.exchangerate-api.com/v6/
de66f6b06d4e3eee31a27a7c /pair/{source}/{destination}/{amount}').json()
# getting the conversion result from response result
converted_result = result['conversion_result']
# formatting the results
formatted_result = f'{amount} {source} = {converted_result}
{destination}'
# adding text to the empty result label
result_label.config(text=formatted_result)
# adding text to the empty time label
time_label.config(text='Last updated,' + result['time_last_update_utc'])
# will catch all the errors that might occur
# ConnectionTimeOut, JSONDecodeError etc
except:
showerror(title='Error', message="An error occurred!!. Fill all the required
field or check your internet connection.")

# creating the main window


window = Tk()

# this gives the window the width(310), height(320) and the position(center)
window.geometry('310x340+500+200')

# this is the title for the window


window.title('Currency Converter')

# this will make the window not resizable, since height and width is FALSE
window.resizable(height=FALSE, width=FALSE)

# colors for the application


primary = '#081F4D'
secondary = '#0083FF'
white = '#FFFFFF'

# the top frame


top_frame = Frame(window, bg=primary, width=300, height=80)
top_frame.grid(row=0, column=0)

# label for the text Currency Converter


name_label = Label(top_frame, text='Currency Converter', bg=primary,
fg=white, pady=30, padx=24, justify=CENTER, font=('Poppins 20 bold'))
name_label.grid(row=0, column=0)

# the bottom frame


bottom_frame = Frame(window, width=300, height=250)
bottom_frame.grid(row=1, column=0)

# widgets inside the bottom frame


from_currency_label = Label(bottom_frame, text='FROM:', font=('Poppins 10
bold'), justify=LEFT)
from_currency_label.place(x=5, y=10)

to_currency_label = Label(bottom_frame, text='TO:', font=('Poppins 10 bold'),


justify=RIGHT)
to_currency_label.place(x=160, y=10)

# this is the combobox for holding from_currencies


from_currency_combo = ttk.Combobox(bottom_frame,
values=list(currencies.keys()), width=14, font=('Poppins 10 bold'))
from_currency_combo.place(x=5, y=30)

# this is the combobox for holding to_currencies


to_currency_combo = ttk.Combobox(bottom_frame,
values=list(currencies.keys()), width=14, font=('Poppins 10 bold'))
to_currency_combo.place(x=160, y=30)
# the label for AMOUNT
amount_label = Label(bottom_frame, text='AMOUNT:', font=('Poppins 10
bold'))
amount_label.place(x=5, y=55)

# entry for amount


amount_entry = Entry(bottom_frame, width=25, font=('Poppins 15 bold'))
amount_entry.place(x=5, y=80)

# an empty label for displaying the result


result_label = Label(bottom_frame, text='', font=('Poppins 10 bold'))
result_label.place(x=5, y=115)

# an empty label for displaying the time


time_label = Label(bottom_frame, text='', font=('Poppins 10 bold'))
time_label.place(x=5, y=135)

# the clickable button for converting the currency


convert_button = Button(bottom_frame, text="CONVERT", bg=secondary,
fg=white, font=('Poppins 10 bold'), command=Convert_Currency)
convert_button.place(x=5, y=165)

# this runs the window infinitely until it is closed


window.mainloop()
OUTPUT
Sample:
If there is an error :
HARDWARE REQUIREMENTS FOR THIS PROGRAM:

SOFTWARE REQUIREMENTS FOR THIS PROGRAM:


You might also like