PNR Status In Python

PNR Status Checker Software In Python

Python

PNR Status Checker Software In Python:- PNR Status In Python me Aaj ham PNR Status check Karne wale hai wo bhi python Main Bane GUI ki help se or ham Sara data fetch karenge like PNR number and train name, current status, booking status etc |

PNR Status Checker Software Ko Banane Ke Liye Hamne Python Tkinter Ka Istemal Kiya Hain |

What Is Tkinter In HindiPython Tkinter Ek PowerFul Gui Banane Wala Module Hai Jis se ham GUI Application Bana Sakte Hai Python Tkinter se Bahut Se Bade Bade GUI Application Banaye Gye Hai Or Iski Sabse Acchi Baat Ye Hai Ki Ye Bahut Easy hai Jise Ham Bilkul Aashan Tarike Se Learn Kar Sakte Hai |

PNR Status Checker Software

Indian Railways Api Ki Help or Python Pnr status API Code ki help Se PNR status and etc data fetch Karne wale hai | Me aapko ab step by step batane wala hu Jis se hame Learn Karne me aashani ho jayegi or Friends agar koi python Django se website bhi banane wale hai to AAP yehi code waha par apply kar sakte hai ye python pnr status api code waha par bhi work Karega |

Step 1: Download Pycharm And Python Request And Json Module

Dosto Python PNR Status Data Fetch karne ke liye Sabse Pahle Hame kuch python module or pycharm ko download karna hoga | Download karne ka link niche diya gya hai aap link par click karke download kar sakte hai |

Download :- Pycharm

Ab Ham Python Ka 2 Module Hai Jiska Name Hai Requests , Json Module Usko Ham ab Download Karte hai wo bhi CMD ki help se | Sabse Pahle Aapko Python ki Directory me jana hai |

Goto This Directory :-C:\Users\PC_Name\AppData\Local\Programs\Python\Python37-32\Scripts

Or Aap Is Directory Me Jane ke Bad Aapko SHIFT + LEFT CLICK press karna hoga | Uske Bad Aapko Open command window here par click karna hoga |

Open command window par click karne ke bad aapko command window open ho jayegi | Open Hone Ke bad aapko RESQUESTS Module download karna hai uske liye aapko ye type karna hoga |

pip install requests

Ye Likhe ne bad aapko ENTER press karna hoga fir requests module aapne aap downlaod ho jayega |

pip install json

Json module ko bhi aapko wese hi download karna hai jese hamne requests module ko download kiya hai | Ye Dono Module Download Karne ke bad aapko step 2 me jana hai |

Step 2: Need Indian Railways Api

Friends Ab Hame Indian Railways Api ki jarurat hai uske liye ham is website jane wale hai us website ka name hai IndianRailapi.com

Indian Railway api :- IndianRainlapi.com

Indian Rail Api Website jane ke bad sabse pahle ragistration karna hoga or fir aapko Login Karna hoga ye website free of cost hai |

Indian Rail Api Website Login Karne Ke bad appko ek Aisa Interface Open Hua Hoga | Open Hone ke bad aapko API KEY kar par click karna hoga jeisa ki upper diye gye image me dikhaya gya hai |

Friends Ho Sakta Hain Ki Ye Login Karne Ke Bad Aapko Ise Buy Karna Pade Kyoki Ab Indian Rail Api Free Main Available Nhi hain.

Yaha Par Aapko Api key ko copy kar lena hoga or fir ham python ke code me ye api add karne wale hai |

Step 3: PNR Checker Software Python Code

Ab Ham Python Code ko Write karne wale hai or fir Pnr status check karne wale hai Wo Bhi Python Tkinter Ki Help Se Bane Software Se |

pip Install tkinter

import tkinter as tk
from tkinter import ttk
from tkinter import *
import tkinter.font as font
import requests , json


win = tk.Tk()
win.title("PNR Stutas Checker")
win.iconbitmap('icon.ico')
win.geometry('1000x500')
win.maxsize(width=950 ,height=500)
win.minsize(width=950 ,height=500)
win.config(bg='DARKSALMON')
heading_font = font.Font(family='Helvetica')
heading_size = font.Font(size=30)


Heading = ttk.Label(win, text = "PNR STATUS CHECKER" ,background='DARKSALMON' , borderwidth=2, relief="groove")
Heading['font']= heading_font
Heading['font'] = heading_size
Heading.grid(row=0,columnspan=4,padx = 255)

lEnter_pnr = ttk.Label(win,text='Enter PNR Number',background="DARKSALMON",borderwidth=2, relief="groove")
lEnter_pnr['font']= heading_font
lenter_pnr = font.Font(size=20)
lEnter_pnr['font'] = lenter_pnr
lEnter_pnr.grid(row=3,column=1 ,pady=40 ,padx=10)


Enter_pnr = ttk.Entry(win)
Enter_pnr.focus_set()
Enter_pnr.grid(row=3,column=2 ,ipady=6 ,ipadx=30 , padx=0)



def procces():
    number1=Entry.get(Enter_pnr)
    pnr_no = number1
    sxp = tk.StringVar()
    E4 = Entry(win, state='readonly',textvariable = sxp)
    E4.grid(row=5, columnspan=6, ipady=115, ipadx=250, padx=20, pady=10)
    a = "https://indianrailapi.com/api/v2/PNRCheck/apikey/44d10aa46d74e7be6ca65710c2fa9ce1/PNRNumber/" + pnr_no + "/"
    dk = requests.get(a)
    result = dk.json()
    if result["ResponseCode"] == '200':
        pnr_number = result['PnrNumber']
        train_name = result["TrainNumber"]
        Journey_class = result["JourneyClass"]
        Chat_Prepared = result["ChatPrepared"]
        from_station = result["From"]
        to_station = result["To"]
        dateof_journey = result["JourneyDate"]
        passengers_list = result["Passangers"]
        sxp.set(
            f"PnrNumber {pnr_number}\nTrain Name {train_name}\nJourney Class {Journey_class}\nChart Preadared {Chat_Prepared}\nFrom Station {from_station} To {to_station}\nJourney Date {dateof_journey}")

        for passenger in passengers_list:
            passenger_num = passenger["Passenger"]

            current_status = passenger["CurrentStatus"]

            booking_status = passenger["BookingStatus"]
            sxp.set(
            	(" passenger number : " + str(passenger_num)
                  + "\n current status : " + str(current_status)
                  + "\n booking_status : " + str(booking_status))
            )

    else:
        sxp.set("Wrong Pnr Number")

btn = ttk.Button(win, text='Sumbit',command = procces)
btn.grid(row =4 ,columnspan= 5 , ipady = 10 , ipadx=10 , padx = 20)

win.mainloop()

Output:

Enter Your PNR Number

Enter Your Correct PNR Number

Also Read This Post :-

Leave a Reply

Your email address will not be published. Required fields are marked *