import requests
import tkinter as tk
from tkinter import *
from tkinter import messagebox
def search():
    try:
        ifsc_code=code.get()
        result=requests.get(f'https://ifsc.razorpay.com/{ifsc_code}').json()
        district.set(result['DISTRICT'])
        contact.set(result['CONTACT'])
        micr.set(result['MICR'])
        state.set(result['STATE'])
        branch.set(result['BRANCH'])
        city.set(result['CITY'])
        address.set(result['ADDRESS'])
        centre.set(result['CENTRE'])
        bank.set(result['BANK'])
        bankcode.set(result['BANKCODE'])
        ifsc.set(result['IFSC'])
    except:
        messagebox.showerror("Error","Somthing get Worng")

window=tk.Tk()
window.title("Bank Details")
window.resizable(0,0)
code=StringVar()
district=StringVar()
contact=StringVar()
micr=StringVar()
state=StringVar()
branch=StringVar()
city=StringVar()
address=StringVar()
centre=StringVar()
bank=StringVar()
bankcode=StringVar()
ifsc=StringVar()
label17=tk.Label(window,text="IFSC CODE",font=("Arial",15,"bold"))
label17.grid(row=0,column=0,padx=10,pady=10)
entry=tk.Entry(window,textvariable=code,width=30)
entry.grid(row=0,column=1,padx=10)
button=tk.Button(window,text="Search",font=("Arial",10,"bold"),border=2,bg="light blue",width=10,height=1,command=search)
button.grid(row=0,column=2,padx=10)
#infomations
label=tk.Label(window,text="IFSC:",font=("Arial",10,"bold")).grid(row=1,sticky=S)
label=tk.Label(window,text="BANK:",font=("Arial",10,"bold")).grid(row=2,sticky=S)
label=tk.Label(window,text="BANKCODE:",font=("Arial",10,"bold")).grid(row=3,sticky=S)
label=tk.Label(window,text="ADDRESS:",font=("Arial",10,"bold")).grid(row=4,sticky=S)
label=tk.Label(window,text="CENTRE:",font=("Arial",10,"bold")).grid(row=5,sticky=S)
label=tk.Label(window,text="BRANCH:",font=("Arial",10,"bold")).grid(row=6,sticky=S)
label=tk.Label(window,text="DISTRICT:",font=("Arial",10,"bold")).grid(row=7,sticky=S)
label=tk.Label(window,text="CONTACT:",font=("Arial",10,"bold")).grid(row=8,sticky=S)
label=tk.Label(window,text="CITY:",font=("Arial",10,"bold")).grid(row=9,sticky=S)
label=tk.Label(window,text="STATE:",font=("Arial",10,"bold")).grid(row=10,sticky=S)
label=tk.Label(window,text="MICR:",font=("Arial",10,"bold")).grid(row=11,sticky=S)
#SHOW DATA
label=tk.Label(window,text="",textvariable=ifsc,font=("Arial",10,"bold")).grid(row=1,column=1,sticky=S)
label=tk.Label(window,text="",textvariable=bank,font=("Arial",10,"bold")).grid(row=2,column=1,sticky=S)
label=tk.Label(window,text="",textvariable=bankcode,font=("Arial",10,"bold")).grid(row=3,column=1,sticky=S)
label=tk.Label(window,text="",textvariable=address,font=("Arial",10,"bold")).grid(row=4,column=1,sticky=S)
label=tk.Label(window,text="",textvariable=centre,font=("Arial",10,"bold")).grid(row=5,column=1,sticky=S)
label=tk.Label(window,text="",textvariable=branch,font=("Arial",10,"bold")).grid(row=6,column=1,sticky=S)
label=tk.Label(window,text="",textvariable=district,font=("Arial",10,"bold")).grid(row=7,column=1,sticky=S)
label=tk.Label(window,text="",textvariable=contact,font=("Arial",10,"bold")).grid(row=8,column=1,sticky=S)
label=tk.Label(window,text="",textvariable=city,font=("Arial",10,"bold")).grid(row=9,column=1,sticky=S)
label=tk.Label(window,text="",textvariable=state,font=("Arial",10,"bold")).grid(row=10,column=1,sticky=S)
label=tk.Label(window,text="",textvariable=micr,font=("Arial",10,"bold")).grid(row=11,column=1,sticky=S)
window.mainloop()
