Create a GUI to search bank information with IFSC Code using Python

13 Dec, 2021
Prerequisite: Python GUI – tkinter
The following program depicts how a GUI application can be formulated using python script to get bank details by using IFSC code. Here, we are using Razorpay IFSC Toolkit to fetch IFSC code. Razorpay IFSC Toolkit processes IFSC codes via their toolkit and return data set. 
Module Needed: requests
Requests allows you to send HTTP/1.1 requests extremely easily. This isn’t built-into Python and thus have to be installed explicitly. 
To install this module simply type the following command into your terminal:
pip install requests
Approach:
Import modules
Pass Url and IFSC code into requests.get() function
Fetch this JSON response
And it returns bank details in a Dict data-type
Program: 
Python3
import requests IFSC_Code ='KKBK0005652'URL = "https://ifsc.razorpay.com/"result = requests.get(URL+IFSC_Code).json()print(result)
 
 
Output:
 
{‘ADDRESS’: ‘NO 1471 SHOP NO 101 UMANG PALACE I FLOOR OPPOSITE PETROL PUMP EXHIBITION ROAD PATNA 800001’,‘CENTRE’: ‘PATNA’,‘MICR CODE’: ‘800485005’,‘CITY’: ‘PATNA’,‘STD CODE’: ‘999’,‘RTGS’: True,‘BRANCH’: ‘PATNA’,‘IMPS’: True,‘CONTACT’: ‘99999999’,‘UPI’: True,‘DISTRICT’: ‘PATNA’,‘STATE’: ‘BIHAR’,‘NEFT’: True,‘MICR’: ‘800485005’,‘BANK’: ‘Kotak Mahindra Bank’,‘BANKCODE’: ‘KKBK’,‘IFSC’: ‘KKBK0005652’}
 
Program 2: (GUI Application for searching Bank details with IFSC Code: concept is similar to the above implementation)
 
Python3
# import modulesfrom tkinter import *from tkinter import messageboximport requests  def getifsc():    try:        IFSC_Code = e.get()        URL = "https://ifsc.razorpay.com/"        result = requests.get(URL+IFSC_Code).json()        Centre.set(result['CENTRE'])        contact.set(result['CONTACT'])        UPI.set(result['UPI'])        CITY.set(result['CITY'])        STATE.set(result['STATE'])        DISTRICT.set(result['DISTRICT'])        IMPS.set(result['IMPS'])        ADDRESS.set(result['ADDRESS'])        BRANCH.set(result['BRANCH'])        STD.set(result['STD CODE'])        MICR.set(result['MICR CODE'])        BANK.set(result['BANK'])        BANKCODE.set(result['BANKCODE'])        IFSC.set(result['IFSC'])    except:        messagebox.showerror("showerror", "Something wrong")  # object of tkinter# and background set for light greymaster = Tk()master.configure(bg='light grey') # Variable Classes in tkinterCentre = StringVar()contact = StringVar()UPI = StringVar()CITY = StringVar()STATE = StringVar()DISTRICT = StringVar()IMPS = StringVar()ADDRESS = StringVar()BRANCH = StringVar()STD = StringVar()MICR = StringVar()BANK = StringVar()BANKCODE = StringVar()IFSC = StringVar()  # Creating label for each information# name using widget LabelLabel(master, text="Enter IFSC Code :", bg="light grey").grid(row=0, sticky=W)Label(master, text="Bank Name :", bg="light grey").grid(row=1, sticky=W)Label(master, text="Centre :", bg="light grey").grid(row=2, sticky=W)Label(master, text="contact :", bg="light grey").grid(row=3, sticky=W)Label(master, text="UPI :", bg="light grey").grid(row=4, sticky=W)Label(master, text="CITY :", bg="light grey").grid(row=5, sticky=W)Label(master, text="STATE :", bg="light grey").grid(row=6, sticky=W)Label(master, text="DISTRICT :", bg="light grey").grid(row=7, sticky=W)Label(master, text="ADDRESS :", bg="light grey").grid(row=8, sticky=W)Label(master, text="BRANCH :", bg="light grey").grid(row=9, sticky=W)Label(master, text="STD :", bg="light grey").grid(row=10, sticky=W)Label(master, text="MICR :", bg="light grey").grid(row=11, sticky=W)Label(master, text="IFSC :", bg="light grey").grid(row=12, sticky=W)  # Creating label for class variable# name using widget EntryLabel(master, text="", textvariable=BANK,      bg="light grey").grid(row=1, column=1, sticky=W)Label(master, text="", textvariable=Centre,      bg="light grey").grid(row=2, column=1, sticky=W)Label(master, text="", textvariable=contact,      bg="light grey").grid(row=3, column=1, sticky=W)Label(master, text="", textvariable=UPI, bg="light grey").grid(    row=4, column=1, sticky=W)Label(master, text="", textvariable=CITY,      bg="light grey").grid(row=5, column=1, sticky=W)Label(master, text="", textvariable=STATE,      bg="light grey").grid(row=6, column=1, sticky=W)Label(master, text="", textvariable=DISTRICT,      bg="light grey").grid(row=7, column=1, sticky=W)Label(master, text="", textvariable=ADDRESS,      bg="light grey").grid(row=8, column=1, sticky=W)Label(master, text="", textvariable=BRANCH,      bg="light grey").grid(row=9, column=1, sticky=W)Label(master, text="", textvariable=STD, bg="light grey").grid(    row=10, column=1, sticky=W)Label(master, text="", textvariable=MICR, bg="light grey").grid(    row=11, column=1, sticky=W)Label(master, text="", textvariable=IFSC, bg="light grey").grid(    row=12, column=1, sticky=W)  e = Entry(master)e.grid(row=0, column=1) # creating a button using the widget# Button that will call the submit functionb = Button(master, text="Show", command=getifsc)b.grid(row=0, column=2, columnspan=2, rowspan=2, padx=5, pady=5) mainloop()
Output:
sagartomar9927
Python Tkinter-exercises
Python-tkinter
python-utility
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.