Advertisement
imroz229

Untitled

Apr 6th, 2024
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 33.11 KB | Source Code | 0 0
  1. #LoginWindow.py
  2. from tkinter import *
  3. from PIL import ImageTk, Image
  4. from pygame._sdl2 import messagebox
  5. from tkcalendar import Calendar
  6. import connection
  7.  
  8.  
  9. class LoginForm:
  10.     def _init_(self, window):
  11.         self.window = window
  12.         self.window.geometry('1200x628')
  13.         self.window.resizable(0, 0)
  14.         self.window.state('zoomed')
  15.  
  16.  
  17.         # Background image
  18.         self.bg_frame = Image.open('images\\background1.png')
  19.         photo = ImageTk.PhotoImage(self.bg_frame)
  20.         self.bg_panel = Label(self.window, image=photo)
  21.         self.bg_panel.image = photo
  22.         self.bg_panel.pack(fill='both', expand='yes')
  23.  
  24.         # Login frame
  25.         self.lgn_frame = Frame(self.window, bg='black', width='843', height='777')
  26.         self.lgn_frame.place(x=300, y=25)
  27.         self.txt = 'WELCOME'
  28.         self.heading = Label(self.lgn_frame, text=self.txt, font=('yu gothic ui', 25, 'bold'), bg='black', fg='white')
  29.         self.heading.place(x=80, y=30, width=300, height=30)
  30.  
  31.         # Left side image
  32.         self.side_image = Image.open('images\\trainnobg.jpg')
  33.         photo = ImageTk.PhotoImage(self.side_image)
  34.         self.side_image_label = Label(self.lgn_frame, image=photo, bg='#040405')
  35.         self.side_image_label.image = photo
  36.         self.side_image_label.place(x=-5, y=-159, width=600, height=900)
  37.  
  38.         # Sign in image
  39.         self.sign_in_image = Image.open('images\\irctclogo.png')
  40.         photo = ImageTk.PhotoImage(self.sign_in_image)
  41.         self.sign_in_image_label = Label(self.lgn_frame, image=photo, bg='black')
  42.         self.sign_in_image_label.image = photo
  43.         self.sign_in_image_label.place(x=750, y=75)
  44.  
  45.         # Book Ticket label
  46.         self.sign_in_image_label = Label(self.lgn_frame, text='Book Ticket', bg='#040405', fg='white', font=('yu gothic ui', 13, 'bold'))
  47.         self.sign_in_image_label.place(x=663, y=300)
  48.  
  49.         # From location
  50.         self.username_label = Label(self.lgn_frame, text='From: ', bg='#040405', font=('yu gothic ui', 13, 'bold'), fg='white')
  51.         self.username_label.place(x=600, y=350)
  52.         self.from_entry = Entry(self.lgn_frame, highlightthickness=0, relief=FLAT, bg='#040405', fg='white', font=('yu gothic ui', 13, 'bold'))
  53.         self.from_entry.place(x=685, y=350, width=270)
  54.         self.username_line = Canvas(self.lgn_frame, width=300, height=2.0, bg='#bdb9b1', highlightthickness=0)
  55.         self.username_line.place(x=600, y=375)
  56.  
  57.         # To location
  58.         self.username_label = Label(self.lgn_frame, text='To: ', bg='#040405', font=('yu gothic ui', 13, 'bold'), fg='white')
  59.         self.username_label.place(x=600, y=450)
  60.         self.to_entry = Entry(self.lgn_frame, highlightthickness=0, relief=FLAT, bg='#040405', fg='white', font=('yu gothic ui', 13, 'bold'))
  61.         self.to_entry.place(x=685, y=450, width=270)
  62.         self.username_line = Canvas(self.lgn_frame, width=300, height=2.0, bg='#bdb9b1', highlightthickness=0)
  63.         self.username_line.place(x=600, y=475)
  64.  
  65.         # Seats
  66.         self.username_label = Label(self.lgn_frame, text='Seats: ', bg='#040405', font=('yu gothic ui', 13, 'bold'), fg='white')
  67.         self.username_label.place(x=600, y=520)
  68.         self.seats_entry = Entry(self.lgn_frame, highlightthickness=0, relief=FLAT, bg='#040405', fg='white', font=('yu gothic ui', 13, 'bold'))
  69.         self.seats_entry.place(x=685, y=520, width=270)
  70.  
  71.         # Scrollbar
  72.         scrollbar_frame = Frame(self.lgn_frame, bg='#040405')
  73.         scrollbar_frame.place(x=600, y=575, height=100)
  74.  
  75.         scrollbar_canvas = Canvas(scrollbar_frame, bg='#040405', highlightthickness=0)
  76.         scrollbar_canvas.pack(side=LEFT, fill=BOTH, expand=True)
  77.  
  78.         scrollbar = Scrollbar(scrollbar_frame, orient=VERTICAL, command=scrollbar_canvas.yview)
  79.         scrollbar.pack(side=RIGHT, fill=Y)
  80.  
  81.         options = ['General', 'Ladies', 'Lower Berth', 'Person with Disability', 'Tatkal', 'Duty Pass']
  82.         self.option_listbox = Listbox(scrollbar_canvas, bg='#040405', fg='white', bd=0, highlightthickness=0, font=('yu gothic ui', 12, 'bold'))
  83.  
  84.         self.username_line = Canvas(self.lgn_frame, width=300, height=2.0, bg='#bdb9b1', highlightthickness=0)
  85.         self.username_line.place(x=600, y=550)
  86.  
  87.         for option in options:
  88.             self.option_listbox.insert(END, option)
  89.         self.option_listbox.pack(side=LEFT, fill=BOTH, expand=True)
  90.  
  91.         self.option_listbox.config(yscrollcommand=scrollbar.set)
  92.  
  93.         # Label to display selected item
  94.         self.selected_label = Label(self.lgn_frame, text="", bg="#040405", fg="white",
  95.                                     font=('yu gothic ui', 12, 'bold'))
  96.         self.selected_label.place(x=680, y=520)
  97.  
  98.         # Bind listbox select event
  99.         self.option_listbox.bind("<<ListboxSelect>>", self.on_select)
  100.  
  101.         # Date
  102.         self.date_label = Label(self.lgn_frame, text='Date: ', bg='#040405', font=('yu gothic ui', 13, 'bold'), fg='white')
  103.         self.date_label.place(x=315, y=500)
  104.         self.username_line = Canvas(self.lgn_frame, width=250, height=2.0, bg='#bdb9b1', highlightthickness=0)
  105.         self.username_line.place(x=315, y=545)
  106.  
  107.         self.cal = Calendar(self.lgn_frame, selectmode="day", year=2024, month=2, day=18, background='#040405',
  108.                             foreground='white', headersbackground='#040405', headersforeground='white')
  109.         self.cal.place(x=300, y=570, width=270)
  110.  
  111.         # Button to get selected date
  112.         self.get_date_button = Button(self.lgn_frame, text="Get Date", command=self.get_date, bg='#040405', fg='white',
  113.                                       font=('yu gothic ui', 13, 'bold'))
  114.         self.get_date_button.place(x=390, y=502, height=25, width=75)
  115.  
  116.         # Label to display selected date
  117.         self.selected_date_label = Label(self.lgn_frame, text="", bg="#040405", fg="white", font=('yu gothic ui', 12, 'bold'))
  118.         self.selected_date_label.place(x=480, y=500)
  119.  
  120.         # Search button
  121.         self.search_button = Button(self.lgn_frame, text="Search", bg='red', fg='white', font=('yu gothic ui', 13, 'bold'), command=self.search_trains_wrapper, cursor='hand2')
  122.         self.search_button.place(x=600, y=695, height=30, width=100)
  123.  
  124.     def get_date(self):
  125.         selected_date = self.cal.get_date()
  126.         self.selected_date_label.config(text=selected_date)
  127.  
  128.     def on_select(self, event):  
  129.         selection = event.widget.curselection()
  130.         if selection:
  131.             index = selection[0]
  132.             data = event.widget.get(index)
  133.             self.selected_label.config(text=data)
  134.  
  135.     def fetch_available_dates(self, ac_tier):
  136.  
  137.         available_dates = [f"2024-03-{day}" for day in range(20, 31)]
  138.         return available_dates
  139.  
  140.     def display_available_dates(self, ac_tier):
  141.         available_dates = self.fetch_available_dates(ac_tier)
  142.  
  143.         dates_window = Toplevel(self.window)
  144.         dates_window.title(f"Available Dates for {ac_tier}")
  145.         dates_window.geometry('1500x400')
  146.  
  147.         dates_frame = Frame(dates_window, bg='#040405')
  148.         dates_frame.pack(fill='both', expand=True)
  149.  
  150.         dates_label = Label(dates_frame, text=f"Available Dates for {ac_tier}", bg='#040405', fg='white', font=('yu gothic ui', 16, 'bold'))
  151.         dates_label.pack(pady=10)
  152.  
  153.         # Create a horizontal scrollbar to display dates
  154.         dates_canvas = Canvas(dates_frame, bg='#040405', highlightthickness=0)
  155.         dates_canvas.pack(side=TOP, fill=BOTH, expand=True)
  156.  
  157.         scrollbar = Scrollbar(dates_frame, orient=HORIZONTAL, command=dates_canvas.xview)
  158.         scrollbar.pack(side=BOTTOM, fill=X)
  159.  
  160.         dates_canvas.configure(xscrollcommand=scrollbar.set)
  161.  
  162.         dates_frame_inner = Frame(dates_canvas, bg='#040405')
  163.         dates_canvas.create_window((0, 0), window=dates_frame_inner, anchor='nw')
  164.  
  165.         # Add dates to the frame
  166.         for i, date in enumerate(available_dates):
  167.             date_button = Button(dates_frame_inner, text=date, bg='red', fg='white', font=('yu gothic ui', 12, 'bold'))
  168.             date_button.grid(row=0, column=i, padx=5, pady=5)
  169.  
  170.         # Update scroll region
  171.         dates_frame_inner.update_idletasks()
  172.         dates_canvas.config(scrollregion=dates_canvas.bbox("all"))
  173.  
  174.  
  175.     def search_trains_wrapper(self):
  176.         from_location = self.from_entry.get()
  177.         to_location = self.to_entry.get()
  178.         date = self.cal.get_date()
  179.  
  180.         if not (from_location and to_location and date):
  181.             # If any of the fields are empty, display a message
  182.             messagebox.showerror("Error", "Please fill in all the required fields.")
  183.             return
  184.  
  185.         # Call search_trains function from connection module
  186.         results = connection.search_trains(from_location, to_location, date)
  187.  
  188.         # Display search results
  189.         if results:
  190.             self.display_search_results(results)
  191.         else:
  192.             messagebox.showinfo("No Results", "No trains found for the given criteria.")
  193.  
  194.  
  195.     def display_search_results(self, results):
  196.         # Function to display search results
  197.         # You can update this method to display the results in a separate window or in the current window
  198.         results_window = Toplevel(self.window)
  199.         results_window.title("Search Results")
  200.         results_window.geometry('800x600')
  201.  
  202.         # Create a frame to hold the results
  203.         results_frame = Frame(results_window, bg='#040405')
  204.         results_frame.pack(fill='both', expand=True)
  205.  
  206.         # Add a label for the heading
  207.         heading_label = Label(results_frame, text="Search Results", bg='#040405', fg='white',
  208.                               font=('yu gothic ui', 18, 'bold'))
  209.         heading_label.pack(pady=10)
  210.  
  211.         if results:
  212.             # Iterate over the results and display them
  213.             for result in results:
  214.                 train_frame = Frame(results_window, bg='#040405')
  215.                 train_frame.pack(fill='both', expand=True)
  216.                 result_label = Label(results_frame, text=result, bg='#040405', fg='white', font=('yu gothic ui', 12))
  217.                 result_label.pack(pady=15, padx=10)
  218.  
  219.         else:
  220.             # If no results found, display a message
  221.             no_results_label = Label(results_frame, text="No trains found for the given criteria.", bg='#040405',
  222.                                      fg='white', font=('yu gothic ui', 12))
  223.             no_results_label.pack(pady=10)
  224.  
  225.         close_button = Button(results_frame, text="Close", command=results_window.destroy, bg='red', fg='white',font=('yu gothic ui', 12, 'bold'),cursor='hand2')
  226.         close_button.place(x=350, y=380)
  227.  
  228.         ACTier1A = Button(results_frame, text="AC Tier 1", bg='red', fg='white', font=('yu gothic ui', 12, 'bold'), command=lambda: self.display_available_dates("AC Tier 1"), cursor='hand2')
  229.         ACTier1A.place(x=200, y=110)
  230.         ACTier2A = Button(results_frame, text="AC Tier 2", bg='red', fg='white', font=('yu gothic ui', 12, 'bold'), command=lambda: self.display_available_dates("AC Tier 2"), cursor='hand2')
  231.         ACTier2A.place(x=350, y=110)
  232.  
  233.         ACTier1A = Button(results_frame, text="AC Tier 1", bg='red', fg='white', font=('yu gothic ui', 12, 'bold'), command=lambda: self.display_available_dates("AC Tier 1"), cursor='hand2')
  234.         ACTier1A.place(x=200, y=190)
  235.         ACTier2A = Button(results_frame, text="AC Tier 2", bg='red', fg='white', font=('yu gothic ui', 12, 'bold'), command=lambda: self.display_available_dates("AC Tier 2"), cursor='hand2')
  236.         ACTier2A.place(x=350, y=190)
  237.  
  238.     def fetch_available_dates(self, ac_tier):
  239.         available_dates = [f"2024-03-{day}" for day in range(20, 31)]  # Mocked available dates
  240.         return available_dates
  241.  
  242.     def fetch_available_seats(self, ac_tier, selected_date):
  243.         # Mocking the seat types based on selected_date and AC tier
  244.         seat_types = {
  245.             "2024-03-20": ["A-21", "B-42", "B-35", "C-44", "C-45"],
  246.             "2024-03-21": ["A-26", "A-27", "B-28", "B-29"],
  247.             "2024-03-22": ["A-30", "A-31", "B-32", "D-11"],
  248.             "2024-03-23": ["A-33", "A-34", "B-35", "C-36", "C-37", "D-12"],
  249.             "2024-03-24": ["A-38", "A-39", "B-40", "C-42", "C-43", "C-44", "D-22"],
  250.             "2024-03-25": ["A-40", "A-41", "B-42", "C-42", "C-46", "C-44", "D-11"],
  251.             "2024-03-26": ["B-42", "B-43", "B-44", "C-11"],
  252.             "2024-03-27": ["A-11", "B-42", "C-42", "B-19"],
  253.             "2024-03-28": ["A-21", "B-42", "C-42", "B-20", "C-20", "D-12"],
  254.             "2024-03-29": ["A-32, B-26", "C-38", "B-7"],
  255.             "2024-03-30": ["A-33", "C-39", "B-40", "C-45,A-41"],
  256.         }
  257.         return seat_types.get(selected_date, [])
  258.  
  259.     def display_available_dates(self, ac_tier):
  260.         available_dates = self.fetch_available_dates(ac_tier)
  261.  
  262.         dates_window = Toplevel(self.window)
  263.         dates_window.title(f"Available Dates for {ac_tier}")
  264.         dates_window.geometry('1500x400')
  265.  
  266.         dates_frame = Frame(dates_window, bg='#040405')
  267.         dates_frame.pack(fill='both', expand=True)
  268.  
  269.         dates_label = Label(dates_frame, text=f"Available Dates for {ac_tier}", bg='#040405', fg='white',
  270.                             font=('yu gothic ui', 16, 'bold'))
  271.         dates_label.pack(pady=10)
  272.  
  273.         # Create a horizontal scrollbar to display dates
  274.         dates_canvas = Canvas(dates_frame, bg='#040405', highlightthickness=0)
  275.         dates_canvas.pack(side=TOP, fill=BOTH, expand=True)
  276.  
  277.         scrollbar = Scrollbar(dates_frame, orient=HORIZONTAL, command=dates_canvas.xview)
  278.         scrollbar.pack(side=BOTTOM, fill=X)
  279.  
  280.         dates_canvas.configure(xscrollcommand=scrollbar.set)
  281.  
  282.         dates_frame_inner = Frame(dates_canvas, bg='#040405')
  283.         dates_canvas.create_window((0, 0), window=dates_frame_inner, anchor='nw')
  284.  
  285.         # Add date buttons to the frame
  286.         for i, date in enumerate(available_dates):
  287.             date_button = Button(dates_frame_inner, text=date, bg='red', fg='white', font=('yu gothic ui', 12, 'bold'),
  288.                                  command=lambda d=date: self.display_available_seats(ac_tier, d))
  289.             date_button.grid(row=0, column=i, padx=5, pady=5)
  290.  
  291.         # Update scroll region
  292.         dates_frame_inner.update_idletasks()
  293.         dates_canvas.config(scrollregion=dates_canvas.bbox("all"))
  294.  
  295.     def display_available_seats(self, ac_tier, selected_date):
  296.         available_seats = self.fetch_available_seats(ac_tier, selected_date)
  297.  
  298.         seats_window = Toplevel(self.window)
  299.         seats_window.title(f"Available Seats for {ac_tier} on {selected_date}")
  300.         seats_window.geometry('500x400')
  301.  
  302.         seats_frame = Frame(seats_window, bg='#040405')
  303.         seats_frame.pack(fill='both', expand=True)
  304.  
  305.         seats_label = Label(seats_frame, text=f"Available Seats for {ac_tier} on {selected_date}", bg='#040405',
  306.                             fg='white', font=('yu gothic ui', 16, 'bold'))
  307.         seats_label.pack(pady=10)
  308.  
  309.  
  310.         if available_seats:
  311.             for i, seat_type in enumerate(available_seats):
  312.                 seat_button = Button(seats_frame, text=seat_type, bg='red', fg='white',
  313.                                      font=('yu gothic ui', 12, 'bold'))
  314.                 seat_button.pack(pady=5)
  315.         else:
  316.             no_seats_label = Label(seats_frame, text="No seats available for the selected date.", bg='#040405',
  317.                                    fg='white', font=('yu gothic ui', 12))
  318.             no_seats_label.pack(pady=10)
  319.  
  320.  
  321.  
  322. def page():
  323.     window = Tk()
  324.     LoginForm(window)
  325.     window.mainloop()
  326.  
  327. if _name_ == '_main_':
  328.     page()
  329.  
  330.  
  331. #signin.py
  332. from tkinter import *
  333. from tkinter.filedialog import Open
  334. from PIL import ImageTk
  335. def display_login_window():
  336.     login_window = Tk()
  337.     login_window.resizable(False, False)
  338.     login_window.title("Login Page")
  339.     login_window.geometry('1080x566')
  340.  
  341. def hide():
  342.     openeye.config(file='eye (1).png')
  343.     passwordEntry.config(show='*')
  344.     eyeButton.config(command=show)
  345.  
  346.  
  347. def show():
  348.     openeye.config(file='visual (1).png')
  349.     passwordEntry.config(show='')
  350.     eyeButton.config(command=hide)
  351.  
  352. def user_enter(event):
  353.     if usernameEntry.get()=='Username':
  354.         usernameEntry.delete(0,END)
  355.  
  356. def password_enter(event):
  357.     if passwordEntry.get()=='Password':
  358.         passwordEntry.delete(0,END)
  359.  
  360.  
  361.  
  362. login_window = Tk()
  363. login_window.resizable(False, False)
  364. login_window.title("Login Page")
  365. login_window.geometry('1080x566')
  366. bgImage = ImageTk.PhotoImage(file='bg_login.jpg')
  367. bgLabel = Label(login_window, image=bgImage)
  368. bgLabel.grid(row=0, column=0)
  369. bgLabel.place(x=0,y=0)
  370. heading = Label(login_window,text='USER LOGIN', font=('Microsoft YaHei UI', 15, 'bold'), fg='navy')
  371. heading.place(x=765, y=100)
  372.  
  373. usernameEntry=Entry(login_window, width=25, font=('Microsoft YaHei UI', 10, 'bold'),bd=0, fg='black')
  374. usernameEntry.place(x=730, y=150)
  375. usernameEntry.insert(0,'Username')
  376. usernameEntry.bind('<FocusIn>', user_enter)
  377. Frame(login_window, width=200, height=2, bg='navy').place(x=730, y=175)
  378.  
  379. passwordEntry = Entry(login_window, width=25, font=('Microsoft YaHei UI', 10, 'bold'), bd=0, fg='black')
  380. passwordEntry.place(x=730, y=185)
  381. passwordEntry.insert(0,'Password')
  382. passwordEntry.bind('<FocusIn>', password_enter)
  383. Frame(login_window, width=200, height=2, bg='navy').place(x=730, y=205)
  384. openeye=PhotoImage(file='visual (1).png')
  385. eyeButton = Button(login_window,image=openeye, bd=0, bg='white', activebackground='white', cursor='hand2', command=hide)
  386. eyeButton.place(x=910,y=190)
  387.  
  388.  
  389. forgetButton = Button(login_window,text='Forgot Password?', bd=0, bg='white', activebackground='white', cursor='hand2', font=('Microsoft YaHei UI',8,'bold'), fg='navy', activeforeground='navy')
  390. forgetButton.place(x=830,y=210)
  391.  
  392. loginButton=Button(login_window, text='Login', font=('Open Sans', 12, 'bold'), fg='white', bg='navy', activeforeground='white', activebackground='navy', cursor='hand2', bd=0, width=19)
  393. loginButton.place(x=735, y=250)
  394.  
  395. orLabel = Label(login_window, text='-----------------OR----------------', font=('Open Sans',12,'bold'), fg='navy', bg='white')
  396. orLabel.place(x=737, y=290)
  397.  
  398. fb_logo=PhotoImage(file='fblogo (1).png')
  399. fb_Label = Label(login_window, image=fb_logo)
  400. fb_Label.place(x=737, y=320)
  401.  
  402. x_logo = PhotoImage(file='xlogo (1).png')
  403. x_Label = Label(login_window, image=x_logo)
  404. x_Label.place(x=817, y=320)
  405.  
  406. google_logo = PhotoImage(file='googlelogo (1).png')
  407. google_Label = Label(login_window, image=google_logo)
  408. google_Label.place(x=887, y=320)
  409.  
  410. signupLabel = Label(login_window, text='Don`t have any account?', font=('Open Sans',8,'bold'), fg='navy', bg='white')
  411. signupLabel.place(x=770, y=350)
  412.  
  413. CreatenewaccButton = Button(login_window, text='Create a new one', font=('Open Sans', 9, 'bold underline'), fg='navy', bg='white', activeforeground='navy', cursor='hand2', bd=0)
  414. CreatenewaccButton.place(x=740, y=380)
  415.  
  416. login_window.mainloop()
  417.  
  418. def search_trains(from_location, to_location, date):
  419.     # Assuming the date is in the format 'YYYY-MM-DD'
  420.     if from_location.lower() == "mumbai" and to_location.lower() == "delhi" or from_location.lower() == "delhi" and to_location.lower() == "mumbai":
  421.         # Dummy timetable for trains from Mumbai to Delhi
  422.         timetable = {
  423.             #month/day/year
  424.             "3/4/24": ["NZM RAJDHANIs - Departure: 08:00 AM, Arrival: 06:00 AM \n\n\n\n Tejas express - Departure: 10:00 AM, Arrival: 06:00 AM\n\n\n"],
  425.             "3/5/24": ["NZM RAJDHANIs - Departure: 08:00 AM, Arrival: 06:00 AM \n\n\n\n Tejas express - Departure: 10:00 AM, Arrival: 06:00 AM\n\n\n"],
  426.             "3/6/24": ["NZM RAJDHANIs - Departure: 08:00 AM, Arrival: 06:00 AM \n\n\n\n Tejas express - Departure: 10:00 AM, Arrival: 06:00 AM\n\n\n"],
  427.             "3/7/24": ["NZM RAJDHANIs - Departure: 08:00 AM, Arrival: 06:00 AM \n\n\n\n Tejas express - Departure: 10:00 AM, Arrival: 06:00 AM\n\n\n"],
  428.             "3/8/24": ["NZM RAJDHANIs - Departure: 08:00 AM, Arrival: 06:00 AM \n\n\n\n Tejas express - Departure: 10:00 AM, Arrival: 06:00 AM\n\n\n"],
  429.             "3/9/24": ["NZM RAJDHANIs - Departure: 08:00 AM, Arrival: 06:00 AM \n\n\n\n Tejas express - Departure: 10:00 AM, Arrival: 06:00 AM\n\n\n"],
  430.             "3/10/24": ["NZM RAJDHANIs -Departure: 08:00 AM, Arrival: 06:00 AM \n\n\n\n Tejas express - Departure: 10:00 AM, Arrival: 06:00 AM\n\n\n"],
  431.             "3/11/24": ["NZM RAJDHANIs -Departure: 08:00 AM, Arrival: 06:00 AM \n\n\n\n Tejas express - Departure: 10:00 AM, Arrival: 06:00 AM\n\n\n"],
  432.             "3/12/24": ["NZM RAJDHANIs -Departure: 08:00 AM, Arrival: 06:00 AM \n\n\n\n Tejas express - Departure: 10:00 AM, Arrival: 06:00 AM\n\n\n"],
  433.             "3/13/24": ["NZM RAJDHANIs -Departure: 08:00 AM, Arrival: 06:00 AM \n\n\n\n Tejas express - Departure: 10:00 AM, Arrival: 06:00 AM\n\n\n"],
  434.             "3/14/24": ["NZM RAJDHANIs -Departure: 08:00 AM, Arrival: 06:00 AM \n\n\n\n Tejas express - Departure: 10:00 AM, Arrival: 06:00 AM\n\n\n"],
  435.             "3/15/24": ["NZM RAJDHANIs -Departure: 08:00 AM, Arrival: 06:00 AM \n\n\n\n Tejas express - Departure: 10:00 AM, Arrival: 06:00 AM\n\n\n"],
  436.             "3/16/24": ["NZM RAJDHANIs -Departure: 08:00 AM, Arrival: 06:00 AM \n\n\n\n Tejas express - Departure: 10:00 AM, Arrival: 06:00 AM\n\n\n"],
  437.             "3/17/24": ["NZM RAJDHANIs -Departure: 08:00 AM, Arrival: 06:00 AM \n\n\n\n Tejas express - Departure: 10:00 AM, Arrival: 06:00 AM\n\n\n"],
  438.             "3/18/24": ["NZM RAJDHANIs -Departure: 08:00 AM, Arrival: 06:00 AM \n\n\n\n Tejas express - Departure: 10:00 AM, Arrival: 06:00 AM\n\n\n"],
  439.             "3/19/24": ["NZM RAJDHANIs -Departure: 08:00 AM, Arrival: 06:00 AM \n\n\n\n Tejas express - Departure: 10:00 AM, Arrival: 06:00 AM\n\n\n"],
  440.             "3/20/24": ["NZM RAJDHANIs -Departure: 08:00 AM, Arrival: 06:00 AM \n\n\n\n Tejas express - Departure: 10:00 AM, Arrival: 06:00 AM\n\n\n"],
  441.             "3/21/24": ["NZM RAJDHANIs -Departure: 08:00 AM, Arrival: 06:00 AM \n\n\n\n Tejas express - Departure: 10:00 AM, Arrival: 06:00 AM\n\n\n"],
  442.             "3/22/24": ["NZM RAJDHANIs -Departure: 08:00 AM, Arrival: 06:00 AM \n\n\n\n Tejas express - Departure: 10:00 AM, Arrival: 06:00 AM\n\n\n"],
  443.             "3/23/24": [
  444.                 "NZM RAJDHANIs -Departure: 08:00 AM, Arrival: 06:00 AM \n\n\n\n Tejas express - Departure: 10:00 AM, Arrival: 06:00 AM\n\n\n"],
  445.             "3/24/24": [
  446.                 "NZM RAJDHANIs -Departure: 08:00 AM, Arrival: 06:00 AM \n\n\n\n Tejas express - Departure: 10:00 AM, Arrival: 06:00 AM\n\n\n"],
  447.             "3/25/24": [
  448.                 "NZM RAJDHANIs -Departure: 08:00 AM, Arrival: 06:00 AM \n\n\n\n Tejas express - Departure: 10:00 AM, Arrival: 06:00 AM\n\n\n"],
  449.             "3/26/24": [
  450.                 "NZM RAJDHANIs -Departure: 08:00 AM, Arrival: 06:00 AM \n\n\n\n Tejas express - Departure: 10:00 AM, Arrival: 06:00 AM\n\n\n"],
  451.             "3/27/24": [
  452.                 "NZM RAJDHANIs -Departure: 08:00 AM, Arrival: 06:00 AM \n\n\n\n Tejas express - Departure: 10:00 AM, Arrival: 06:00 AM\n\n\n"],
  453.             "3/28/24": [
  454.                 "NZM RAJDHANIs -Departure: 08:00 AM, Arrival: 06:00 AM \n\n\n\n Tejas express - Departure: 10:00 AM, Arrival: 06:00 AM\n\n\n"],
  455.             "3/29/24": [
  456.                 "NZM RAJDHANIs -Departure: 08:00 AM, Arrival: 06:00 AM \n\n\n\n Tejas express - Departure: 10:00 AM, Arrival: 06:00 AM\n\n\n"],
  457.             "3/30/24": [
  458.                 "NZM RAJDHANIs -Departure: 08:00 AM, Arrival: 06:00 AM \n\n\n\n Tejas express - Departure: 10:00 AM, Arrival: 06:00 AM\n\n\n"],
  459.             "3/31/24": [
  460.                 "NZM RAJDHANIs -Departure: 08:00 AM, Arrival: 06:00 AM \n\n\n\n Tejas express - Departure: 10:00 AM, Arrival: 06:00 AM\n\n\n"],
  461.  
  462.  
  463.         }
  464.     elif from_location.lower() == "mumbai" and to_location.lower() == "chennai" or from_location.lower() == "chennai" and to_location.lower() == "mumbai":
  465.         # Dummy timetable for trains from Mumbai to Chennai
  466.         timetable = {
  467.             "3/5/24": ["Mumbai to Chennai Express - Departure: 09:00 AM, Arrival: 08:00 PM \n\n\n\n Mumbai to Chennai Superfast - Departure: 11:00 AM, Arrival: 10:00 PM"],
  468.             "3/6/24": ["Mumbai to Chennai Express - Departure: 09:00 AM, Arrival: 08:00 PM \n\n\n\n Mumbai to Chennai Superfast - Departure: 11:00 AM, Arrival: 10:00 PM"],
  469.             "3/7/24": ["Mumbai to Chennai Express - Departure: 09:00 AM, Arrival: 08:00 PM \n\n\n\nMumbai to Chennai Superfast - Departure: 11:00 AM, Arrival: 10:00 PM"],
  470.             "3/8/24": ["Mumbai to Chennai Express - Departure: 09:00 AM, Arrival: 08:00 PM \n\n\n\n Mumbai to Chennai Superfast - Departure: 11:00 AM, Arrival: 10:00 PM"],
  471.             "3/9/24": ["Mumbai to Chennai Express - Departure: 09:00 AM, Arrival: 08:00 PM \n\n\n\n Mumbai to Chennai Superfast - Departure: 11:00 AM, Arrival: 10:00 PM"],
  472.             "3/10/24": [ "Mumbai to Chennai Express - Departure: 09:00 AM, Arrival: 08:00 PM \n\n\n Mumbai to Chennai Superfast - Departure: 11:00 AM, Arrival: 10:00 PM"],
  473.             "3/11/24": ["Mumbai to Chennai Express - Departure: 09:00 AM, Arrival: 08:00 PM \n\n\n Mumbai to Chennai Superfast - Departure: 11:00 AM, Arrival: 10:00 PM"],
  474.             "3/12/24": [ "Mumbai to Chennai Express - Departure: 09:00 AM, Arrival: 08:00 PM \n Mumbai to Chennai Superfast - Departure: 11:00 AM, Arrival: 10:00 PM"],
  475.             "3/13/24": [ "Mumbai to Chennai Express - Departure: 09:00 AM, Arrival: 08:00 PM \n Mumbai to Chennai Superfast - Departure: 11:00 AM, Arrival: 10:00 PM"],
  476.             "3/14/24": ["Mumbai to Chennai Express - Departure: 09:00 AM, Arrival: 08:00 PM \n Mumbai to Chennai Superfast - Departure: 11:00 AM, Arrival: 10:00 PM"],
  477.             "3/15/24": ["Mumbai to Chennai Express - Departure: 09:00 AM, Arrival: 08:00 PM \n Mumbai to Chennai Superfast - Departure: 11:00 AM, Arrival: 10:00 PM"],
  478.             "3/16/24": [ "Mumbai to Chennai Express - Departure: 09:00 AM, Arrival: 08:00 PM \n Mumbai to Chennai Superfast - Departure: 11:00 AM, Arrival: 10:00 PM"],
  479.             "3/17/24": ["Mumbai to Chennai Express - Departure: 09:00 AM, Arrival: 08:00 PM \n Mumbai to Chennai Superfast - Departure: 11:00 AM, Arrival: 10:00 PM"],
  480.             "3/18/24": ["Mumbai to Chennai Express - Departure: 09:00 AM, Arrival: 08:00 PM \n Mumbai to Chennai Superfast - Departure: 11:00 AM, Arrival: 10:00 PM"],
  481.             "3/19/24": ["Mumbai to Chennai Express - Departure: 09:00 AM, Arrival: 08:00 PM \n\n\n\n Mumbai to Chennai Superfast - Departure: 11:00 AM, Arrival: 10:00 PM"],
  482.             "3/20/24": ["Mumbai to Chennai Express - Departure: 09:00 AM, Arrival: 08:00 PM \n\n\n\n Mumbai to Chennai Superfast - Departure: 11:00 AM, Arrival: 10:00 PM"],
  483.             "3/21/24": ["Mumbai to Chennai Express - Departure: 09:00 AM, Arrival: 08:00 PM \n\n\n\n Mumbai to Chennai Superfast - Departure: 11:00 AM, Arrival: 10:00 PM"],
  484.             "3/22/24": ["Mumbai to Chennai Express - Departure: 09:00 AM, Arrival: 08:00 PM \n\n\n\n Mumbai to Chennai Superfast - Departure: 11:00 AM, Arrival: 10:00 PM"],
  485.             "3/23/24": ["Mumbai to Chennai Express - Departure: 09:00 AM, Arrival: 08:00 PM \n\n\n\n Mumbai to Chennai Superfast - Departure: 11:00 AM, Arrival: 10:00 PM"],
  486.             "3/24/24": ["Mumbai to Chennai Express - Departure: 09:00 AM, Arrival: 08:00 PM \n\n\n\n Mumbai to Chennai Superfast - Departure: 11:00 AM, Arrival: 10:00 PM"],
  487.             "3/25/24": ["Mumbai to Chennai Express - Departure: 09:00 AM, Arrival: 08:00 PM \n\n\n\n Mumbai to Chennai Superfast - Departure: 11:00 AM, Arrival: 10:00 PM"],
  488.             "3/26/24": ["Mumbai to Chennai Express - Departure: 09:00 AM, Arrival: 08:00 PM \n\n\n\n Mumbai to Chennai Superfast - Departure: 11:00 AM, Arrival: 10:00 PM"],
  489.             "3/27/24": ["Mumbai to Chennai Express - Departure: 09:00 AM, Arrival: 08:00 PM \n\n\n\n Mumbai to Chennai Superfast - Departure: 11:00 AM, Arrival: 10:00 PM"],
  490.             "3/28/24": ["Mumbai to Chennai Express - Departure: 09:00 AM, Arrival: 08:00 PM \n\n\n\n Mumbai to Chennai Superfast - Departure: 11:00 AM, Arrival: 10:00 PM"],
  491.             "3/29/24": ["Mumbai to Chennai Express - Departure: 09:00 AM, Arrival: 08:00 PM \n\n\n\n Mumbai to Chennai Superfast - Departure: 11:00 AM, Arrival: 10:00 PM"],
  492.             "3/30/24": ["Mumbai to Chennai Express - Departure: 09:00 AM, Arrival: 08:00 PM \n\n\n\n Mumbai to Chennai Superfast - Departure: 11:00 AM, Arrival: 10:00 PM"],
  493.             "3/31/24": ["Mumbai to Chennai Express - Departure: 09:00 AM, Arrival: 08:00 PM \n\n\n\n Mumbai to Chennai Superfast - Departure: 11:00 AM, Arrival: 10:00 PM"],
  494.             "4/1/24": ["Mumbai to Chennai Express - Departure: 09:00 AM, Arrival: 08:00 PM \n\n\n\n Mumbai to Chennai Superfast - Departure: 11:00 AM, Arrival: 10:00 PM"],
  495.  
  496.  
  497.         }
  498.     elif from_location.lower() == "amritsar" and to_location.lower() == "mumbai" or from_location.lower() == "mumbai" and to_location.lower() == "amritsar":
  499.         timetable = {
  500.             "3/5/24": ["Golden temple Express - Departure: 09:00 AM, Arrival: 08:00 PM \n Mumbai CSMT express - Departure: 11:00 AM, Arrival: 10:00 PM"],
  501.             "3/6/24": ["Golden temple Express - Departure: 09:00 AM, Arrival: 08:00 PM \n Mumbai CSMT express - Departure: 11:00 AM, Arrival: 10:00 PM"],
  502.             "3/7/24": ["Golden temple Express - Departure: 09:00 AM, Arrival: 08:00 PM \n Mumbai CSMT express - Departure: 11:00 AM, Arrival: 10:00 PM"],
  503.             "3/8/24": ["Golden temple Express - Departure: 09:00 AM, Arrival: 08:00 PM \n Mumbai CSMT express - Departure: 11:00 AM, Arrival: 10:00 PM"],
  504.             "3/9/24": ["Golden temple Express - Departure: 09:00 AM, Arrival: 08:00 PM \n Mumbai CSMT express - Departure: 11:00 AM, Arrival: 10:00 PM"],
  505.             "3/10/24": ["Golden temple Express - Departure: 09:00 AM, Arrival: 08:00 PM \n\n\n Mumbai CSMT express - Departure: 11:00 AM, Arrival: 10:00 PM"],
  506.             "3/11/24": ["Golden temple Express - Departure: 09:00 AM, Arrival: 08:00 PM \n\n\n Mumbai CSMT express - Departure: 11:00 AM, Arrival: 10:00 PM"],
  507.             "3/12/24": ["Golden temple Express - Departure: 09:00 AM, Arrival: 08:00 PM \n\n\n Mumbai CSMT express - Departure: 11:00 AM, Arrival: 10:00 PM"],
  508.             "3/13/24": ["Golden temple Express - Departure: 09:00 AM, Arrival: 08:00 PM \n\n\n Mumbai CSMT express - Departure: 11:00 AM, Arrival: 10:00 PM"],
  509.             "3/14/24": ["Golden temple Express - Departure: 09:00 AM, Arrival: 08:00 PM \n\n\n Mumbai CSMT express - Departure: 11:00 AM, Arrival: 10:00 PM"],
  510.             "3/15/24": ["Golden temple Express - Departure: 09:00 AM, Arrival: 08:00 PM \n\n\n Mumbai CSMT express - Departure: 11:00 AM, Arrival: 10:00 PM"],
  511.             "3/16/24": ["Golden temple Express - Departure: 09:00 AM, Arrival: 08:00 PM \n\n\n Mumbai CSMT express - Departure: 11:00 AM, Arrival: 10:00 PM"],
  512.             "3/17/24": ["Golden temple Express - Departure: 09:00 AM, Arrival: 08:00 PM \n\n\n Mumbai CSMT express - Departure: 11:00 AM, Arrival: 10:00 PM"],
  513.             "3/18/24": ["Golden temple Express - Departure: 09:00 AM, Arrival: 08:00 PM \n\n\n Mumbai CSMT express - Departure: 11:00 AM, Arrival: 10:00 PM"],
  514.             "3/19/24": ["Golden temple Express - Departure: 09:00 AM, Arrival: 08:00 PM \n\n\n Mumbai CSMT express - Departure: 11:00 AM, Arrival: 10:00 PM"],
  515.             "3/20/24": ["Golden temple Express - Departure: 09:00 AM, Arrival: 08:00 PM \n\n\n Mumbai CSMT express - Departure: 11:00 AM, Arrival: 10:00 PM"],
  516.             "3/21/24": ["Golden temple Express - Departure: 09:00 AM, Arrival: 08:00 PM \n\n\n Mumbai CSMT express - Departure: 11:00 AM, Arrival: 10:00 PM"],
  517.             "3/22/24": ["Golden temple Express - Departure: 09:00 AM, Arrival: 08:00 PM \n\n\n Mumbai CSMT express - Departure: 11:00 AM, Arrival: 10:00 PM"],
  518.             "3/23/24": ["Golden temple Express - Departure: 09:00 AM, Arrival: 08:00 PM \n\n\n Mumbai CSMT express - Departure: 11:00 AM, Arrival: 10:00 PM"],
  519.             "3/24/24": ["Golden temple Express - Departure: 09:00 AM, Arrival: 08:00 PM \n\n\n Mumbai CSMT express - Departure: 11:00 AM, Arrival: 10:00 PM"],
  520.             "3/25/24": ["Golden temple Express - Departure: 09:00 AM, Arrival: 08:00 PM \n\n\n Mumbai CSMT express - Departure: 11:00 AM, Arrival: 10:00 PM"],
  521.             "3/26/24": ["Golden temple Express - Departure: 09:00 AM, Arrival: 08:00 PM \n\n\n Mumbai CSMT express - Departure: 11:00 AM, Arrival: 10:00 PM"],
  522.             "3/27/24": ["Golden temple Express - Departure: 09:00 AM, Arrival: 08:00 PM \n\n\n Mumbai CSMT express - Departure: 11:00 AM, Arrival: 10:00 PM"],
  523.             "3/28/24": ["Golden temple Express - Departure: 09:00 AM, Arrival: 08:00 PM \n\n\n Mumbai CSMT express - Departure: 11:00 AM, Arrival: 10:00 PM"],
  524.             "3/29/24": ["Golden temple Express - Departure: 09:00 AM, Arrival: 08:00 PM \n\n\n Mumbai CSMT express - Departure: 11:00 AM, Arrival: 10:00 PM"],
  525.             "3/30/24": ["Golden temple Express - Departure: 09:00 AM, Arrival: 08:00 PM \n\n\n Mumbai CSMT express - Departure: 11:00 AM, Arrival: 10:00 PM"],
  526.  
  527.         }
  528.     else:
  529.         # For other destinations or invalid inputs
  530.         return ["No trains found for the given criteria."]
  531.  
  532.     # Check if there are schedules available for the provided date
  533.     if date in timetable:
  534.         return timetable[date]
  535.     else:
  536.         return ["No trains available on the selected date or incomplete data is provided."]
  537.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement