### how to create simple currency converting app using python

hello hackers,

#### Today, I am Going To Show You How To Create Simple Currency Converting App Using Python?.

In Today's Time,

Currency Converting Apps Are Very Useful Because, with the help of this app, we can do currency conversion calculation very easily and fastly. As We Already Know Python Programming Language Features Like Cross-Platform Support, Very Easy, Wide Range Of Library Availability And Etc Etc.

#### Q 1. Which GUI library is suitable for This App?

Ans. In This Tutorial, I am using Python Tkinter Module Because Of its Easy Structured Programming and Built-In Availability.

If You are also new in Python Tkinter Module.

Now, Let's Focus On Our Main Topic.

To do currency conversion calculation, we will use some basic mathematics formulas.
like

#### For Currency Conversion Formula,

converted_curency  =  currency_rate * currency_for_conversion

As according to this formula first, we will takes currency rate price as input from the user, and then multiply currency rate price with provided currency for conversion.

Simple! hahaha

Now, we Just Need to create a GUI Apps That Can Do This Simple Calculation Very Easily.

Here, In my codes I Am Using

"
```# Import Module
try:
import Tkinter
import ttk
except:
import tkinter as Tkinter
import tkinter.ttk as ttk```

"
method to import tkinter module. Why? Because Tkinter Library Name in Python 2.x is "Tkinter" And "tkinter" in Python 3.x. So, To Make My Code Compatible With Both I Am Using try and except method.

### 1. Python Simple Currency Converting App

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78``` ```#!/usr/bin/python # -*- coding: utf-8 -*- # # Written By: # S.S.B # surajsinghbisht054@gmail.com # bitforestinfo.blogspot.com # # # # ################################################## ######## Please Don't Remove Author Name ######### ############### Thanks ########################### ################################################## # # # Import Module try: import Tkinter import ttk except: import tkinter as Tkinter import tkinter.ttk as ttk # Creating Main Class class converter(Tkinter.Tk): def __init__(self, *args, **kwargs): Tkinter.Tk.__init__(self, *args, **kwargs) self['padx']=50 self['pady']=50 self['bg']="powder blue" self.create_variable_stores() self.create_dashboard() self.create_conversion_mechanizism() # Event Function def convert_base_to_currency(self, *args, **kwargs): try: obj = self.converting_currency.get() * self.Currency_rates.get() self.converted_currency.set(obj) except: pass return # Creating Main Conversion Mechanizm def create_conversion_mechanizism(self): ttk.Entry(self, textvariable=self.converting_currency, font=("arial 30 bold")).grid(row=4, column=1) ttk.Entry(self, textvariable=self.converted_currency, font=("arial 30 bold")).grid(row=4, column=3) return # Creating Main DashBoard def create_dashboard(self): ttk.Label(self, text=" Base Currency ", font=("arial 30 bold")).grid(row=1, column=1, padx=10, pady=10) ttk.Separator(self, orient="vertical").grid(row=1, column=2,sticky="ns", padx=10, pady=10) ttk.Label(self, text=" Currency ", font=("arial 30 bold")).grid(row=1, column=3, padx=10, pady=10) ttk.Label(self, text=" \$ 1 = ", font=("arial 30 bold")).grid(row=2, column=1, padx=10, pady=10) ttk.Entry(self, textvariable=self.Currency_rates, font=("arial 30 bold")).grid(row=2, column=3, padx=10, pady=10) return # Creating Variables def create_variable_stores(self): self.Currency_rates = Tkinter.DoubleVar() self.converted_currency = Tkinter.DoubleVar() self.converting_currency = Tkinter.DoubleVar() # Adding Auto Trace Variable Event self.converting_currency.trace_variable("w", self.convert_base_to_currency) # Main Function def main(): root = converter(className = " Simple Currency Converter") root.mainloop() return # Main Trigger if __name__ == '__main__': main() ```

#### Done!

As  you can see, i tried my best to write these very easy to understand and cross platform supported.

If You really Like This tutorial then you can also download this example from my GitHub Repository. Click Here

if you like my blog,
1. 