0% found this document useful (0 votes)
23 views16 pages

Project Report

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views16 pages

Project Report

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 16

Project Report: Airline Reservation System

1. Introduction

The Airline Reservation System (ARS) is a graphical user interface (GUI)


application developed using Python and the Tkinter library. It allows users to
book flights by selecting airlines, choosing seats, and specifying preferences
such as food and class of travel. The application integrates seat selection, flight
details, and user inputs, providing a seamless booking experience.

2. Objectives

The primary objectives of this project are:

- To create an interactive and user-friendly GUI for flight bookings.


- To manage flight information, including departure and arrival times, prices,
and airline details.
- To implement a seat selection mechanism that limits the number of seats a
user can book.
- To handle user preferences for food and class of travel effectively.
- To provide confirmation messages for successful bookings and error handling
for invalid inputs.

3. Technologies Used

- Programming Language:** Python

- Libraries:**
- Tkinter:** For creating the GUI.
- Pandas:** For handling flight data in a structured format (DataFrame).
- PIL (Pillow):** For image handling and displaying airline logos.
- tkcalendar:** For date selection with a calendar interface.

4. System Architecture

The architecture of the Airline Reservation System consists of the following


components:

4.1 User Interface

- Main Window:** Contains all elements for user interaction, including flight
details, seat selection, and booking options.
- Scrollable Layout:** A canvas with a vertical scrollbar to accommodate
various widgets without cluttering the interface.
- Seating Chart:** A grid layout of buttons representing available and booked
seats.

4.2 Data Handling

- Flight Data: Managed using a Pandas DataFrame, containing flight details like
airline names, flight IDs, departure/arrival times, and prices.
- Airline Information: A dictionary that holds airline logos and flight IDs for easy
access when an airline is selected.

5. Features

5.1 Flight Selection


- Users can view available flights from a listbox, which displays information like
airline, flight ID, departure and arrival times, and prices.

5.2 Seat Selection

- A grid of buttons represents seats, where 'O' indicates an available seat and
'X' indicates a booked seat.
- Users can select a maximum number of seats as specified in the booking
details. If they exceed this limit, a warning message is displayed.

5.3 Booking Details

- Users can select their preferred airline, number of seats, travel class
(Economy, Business, First Class), food preference, and departure/arrival
airports.
- Upon booking, a confirmation message is displayed, summarizing the booking
details.

5.4 Error Handling

- The system includes error handling for invalid inputs, such as non-integer
values for seat numbers, and provides user-friendly warning messages.

6. Code Explanation

The code is structured as a single class, `AirlineReservationSystem`, which


encapsulates all the functionalities required for the application. Key methods
include:
- ‘__init__`: Initializes the application, setting up the main window and various
components.
- `create_scrollable_layout`: Sets up a scrollable area to contain all flight and
booking details.
- `create_seating_chart`: Displays the seating arrangement using buttons.
- `toggle_seat`: Manages seat selection and deselection logic.
- `book_flight`: Validates the booking and displays a confirmation message or
error.
- `reset_seating`* Resets the seating chart after a booking is confirmed.
- `update_airline_logo_and_flight_id`: Updates the logo and flight ID based on
the selected airline.

6.1 Data Initialization

The flight data is initialized in the `__main__` block using a Pandas DataFrame,
which is passed to the `AirlineReservationSystem` class.

7. User Interface Design

The UI design emphasizes simplicity and usability:

- A clear layout separating the seating chart and booking details.


- Intuitive controls for selecting options.
- A responsive design that adjusts to window resizing.

8.Source Code
import tkinter as tk
from tkinter import messagebox, Toplevel
from tkinter.simpledialog import askstring
from PIL import Image, ImageTk
import pandas as pd
from tkcalendar import DateEntry

class AirlineReservationSystem:
def __init__(self, root, rows, cols, flights_df):
self.root = root
self.rows = rows
self.cols = cols
self.flights_df = flights_df
self.seats = [['O' for _ in range(cols)] for _ in range(rows)]
self.buttons = [[None for _ in range(cols)] for _ in range(rows)]
self.selected_seats = []
self.max_seats = 0
self.food_preference = None
self.class_preference = None

self.airline_data = {
'Emirates': {'logo': 'emirates_logo.png', 'flight_id': '101'},
'Etihad': {'logo': 'etihad_logo.png', 'flight_id': '102'},
'Singapore Airlines': {'logo': 'singapore_airlines_logo.png', 'flight_id':
'103'},
'Qatar Airways': {'logo': 'qatar_airways_logo.png', 'flight_id': '104'},
'Air India': {'logo': 'air_india_logo.png', 'flight_id': '105'},
'United Airlines': {'logo': 'united_airlines_logo.png', 'flight_id': '106'},
'British Airways': {'logo': 'british_airlines_logo.png', 'flight_id': '107'},
'Delta Airlines': {'logo': 'delta_airlines_logo.png', 'flight_id': '108'},
'Lufthansa': {'logo': 'lufthansa_logo.png', 'flight_id': '109'},
'Turkish Airlines': {'logo': 'turkish_airlines_logo.png', 'flight_id': '110'}
}

self.root.title("Airline Reservation System")


self.root.geometry("1200x800")

self.create_scrollable_layout()
self.add_datepickers()
self.create_available_flights_panel()

def create_scrollable_layout(self):
self.canvas = tk.Canvas(self.root)
self.scrollbar = tk.Scrollbar(self.root, orient="vertical",
command=self.canvas.yview)
self.canvas.config(yscrollcommand=self.scrollbar.set)
self.canvas.pack(fill=tk.BOTH, expand=True, side=tk.LEFT)
self.scrollbar.pack(side=tk.RIGHT, fill=tk.Y)

self.scrollable_frame = tk.Frame(self.canvas)
self.canvas.create_window((0, 0), window=self.scrollable_frame,
anchor="nw")
self.scrollable_frame.bind(
"<Configure>",
lambda e: self.canvas.configure(scrollregion=self.canvas.bbox("all"))
)
self.create_layout(self.scrollable_frame)
def create_layout(self, frame):
self.pane = tk.PanedWindow(frame, orient=tk.HORIZONTAL)
self.pane.pack(fill=tk.BOTH, expand=True)

left_frame = tk.Frame(self.pane, width=400, height=800)


left_frame.pack_propagate(False)
self.pane.add(left_frame)

right_frame = tk.Frame(self.pane, width=600, height=800)


right_frame.pack_propagate(False)
self.pane.add(right_frame)

self.create_seating_chart(right_frame)
self.create_booking_details(left_frame)

def add_datepickers(self):
date_frame = tk.Frame(self.root)
date_frame.place(relx=0.4, rely=0.7, anchor="center")

tk.Label(date_frame, text="Departure Date:", font=("Arial",


12)).grid(row=0, column=0, padx=5, pady=5)
self.departure_date_entry = DateEntry(date_frame, font=("Arial", 12),
date_pattern='yyyy-mm-dd')
self.departure_date_entry.grid(row=0, column=1, padx=5, pady=5)
tk.Label(date_frame, text="Arrival Date:", font=("Arial", 12)).grid(row=1,
column=0, padx=5, pady=5)
self.arrival_date_entry = DateEntry(date_frame, font=("Arial", 12),
date_pattern='yyyy-mm-dd')
self.arrival_date_entry.grid(row=1, column=1, padx=5, pady=5)

def create_available_flights_panel(self):
flights_frame = tk.Frame(self.root, bd=2, relief=tk.RAISED)
flights_frame.place(relx=0.8, rely=0.1, anchor="n", width=350,
height=400)

tk.Label(flights_frame, text="Available Flights", font=("Arial",


16)).pack(pady=10)

# Create a listbox to display available flights


self.flights_listbox = tk.Listbox(flights_frame, width=50, height=20)
self.flights_listbox.pack(pady=10)

# Insert available flights into the listbox


for index, row in self.flights_df.iterrows():
flight_info = f"{row['Airline']} - {row['Flight ID']} - Departure:
{row['Departure Time']} - Arrival: {row['Arrival Time']} - Price: ${row['Price']}"
self.flights_listbox.insert(tk.END, flight_info)

def create_booking_details(self, frame):


tk.Label(frame, text="Select Airline:", font=("Arial", 14)).pack(pady=10)
airline_options = list(self.airline_data.keys())
self.selected_airline_var = tk.StringVar(value=airline_options[0])
airline_menu = tk.OptionMenu(frame, self.selected_airline_var,
*airline_options)
airline_menu.config(font=("Arial", 14))
airline_menu.pack(pady=10)
self.selected_airline_var.trace('w', self.update_airline_logo_and_flight_id)

self.logo_label = tk.Label(frame, bg="#F8C8D0")


self.logo_label.pack(pady=20)

tk.Label(frame, text="Enter Flight ID:", font=("Arial", 10)).pack(pady=1)


self.flight_id_entry = tk.Entry(frame, font=("Arial", 10))
self.flight_id_entry.pack(pady=5)

tk.Label(frame, text="Number of Seats:", font=("Arial", 10)).pack(pady=1)


self.num_seats_entry = tk.Entry(frame, font=("Arial", 10))
self.num_seats_entry.pack(pady=5)

tk.Label(frame, text="Select Class:", font=("Arial", 10)).pack(pady=1)


class_options = ["Economy", "Business", "First Class"]
self.class_preference_var = tk.StringVar(value=class_options[0])
class_menu = tk.OptionMenu(frame, self.class_preference_var,
*class_options)
class_menu.config(font=("Arial", 10))
class_menu.pack(pady=1)

tk.Label(frame, text="Select Food Preference:", font=("Arial",


10)).pack(pady=10)
food_options = ["Vegetarian", "Non-Vegetarian", "Vegan", "Gluten-Free"]
self.food_preference_var = tk.StringVar(value=food_options[0])
food_menu = tk.OptionMenu(frame, self.food_preference_var,
*food_options)
food_menu.config(font=("Arial", 10))
food_menu.pack(pady=10)

tk.Label(frame, text="Select Departure Airport:", font=("Arial",


10)).pack(pady=10)
self.departure_airport_var = tk.StringVar(value="LAX (Los Angeles)")
departure_airport_menu = tk.OptionMenu(frame,
self.departure_airport_var, "LAX (Los Angeles)", "JFK (New York)", "ORD
(Chicago)")
departure_airport_menu.config(font=("Arial", 10))
departure_airport_menu.pack(pady=10)

tk.Label(frame, text="Select Arrival Airport:", font=("Arial",


10)).pack(pady=10)
self.arrival_airport_var = tk.StringVar(value="JFK (New York)")
arrival_airport_menu = tk.OptionMenu(frame, self.arrival_airport_var,
"JFK (New York)", "LAX (Los Angeles)", "ORD (Chicago)")
arrival_airport_menu.config(font=("Arial", 10))
arrival_airport_menu.pack(pady=10)

book_button = tk.Button(frame, text="Book Flight",


command=self.book_flight, font=("Arial", 12), bg="#4CAF50", fg="white")
book_button.pack(pady=20)
def create_seating_chart(self, frame):
for row in range(self.rows):
for col in range(self.cols):
button = tk.Button(frame, text='O', width=4, height=2,
command=lambda r=row, c=col: self.toggle_seat(r, c))
button.grid(row=row, column=col, padx=5, pady=5) # Use grid for
better alignment
self.buttons[row][col] = button

def toggle_seat(self, row, col):


if self.seats[row][col] == 'O':
if len(self.selected_seats) < self.max_seats:
self.seats[row][col] = 'X'
self.selected_seats.append(f"{row + 1}-{col + 1}") # Store seat names
as "row-col"
self.buttons[row][col].config(text='X', bg='red')
else:
messagebox.showwarning("Warning", f"You can select a maximum of
{self.max_seats} seats.")
else:
self.seats[row][col] = 'O'
self.selected_seats.remove(f"{row + 1}-{col + 1}")
self.buttons[row][col].config(text='O', bg='lightgreen')

def update_airline_logo_and_flight_id(self, *args):


selected_airline = self.selected_airline_var.get()
logo_info = self.airline_data[selected_airline]
logo_path = logo_info['logo']
flight_id = logo_info['flight_id']

# Load and display the airline logo


logo_image = Image.open(logo_path).resize((200, 100), Image.ANTIALIAS)
logo_photo = ImageTk.PhotoImage(logo_image)
self.logo_label.config(image=logo_photo)
self.logo_label.image = logo_photo # Keep a reference to avoid garbage
collection

# Update the flight ID entry


self.flight_id_entry.delete(0, tk.END)
self.flight_id_entry.insert(0, flight_id)

def book_flight(self):
try:
selected_airline = self.selected_airline_var.get()
flight_id = self.flight_id_entry.get()
num_seats = int(self.num_seats_entry.get())
if num_seats <= 0:
raise ValueError("Number of seats must be greater than 0.")
self.max_seats = num_seats

if len(self.selected_seats) > num_seats:


messagebox.showwarning("Warning", f"You can only book
{num_seats} seats.")
return

if not self.selected_seats:
messagebox.showwarning("Warning", "Please select at least one
seat.")
return

# Display confirmation message


confirmation_message = (
f"Flight booked successfully!\n"
f"Airline: {selected_airline}\n"
f"Flight ID: {flight_id}\n"
f"Number of Seats: {len(self.selected_seats)}\n"
f"Class: {self.class_preference_var.get()}\n"
f"Food Preference: {self.food_preference_var.get()}\n"
f"Departure Airport: {self.departure_airport_var.get()}\n"
f"Arrival Airport: {self.arrival_airport_var.get()}\n"
f"Seats Selected: {', '.join(self.selected_seats)}"
)
messagebox.showinfo("Confirmation", confirmation_message)

self.reset_seating()

except ValueError as ve:


messagebox.showerror("Error", str(ve))
except Exception as e:
messagebox.showerror("Error", str(e))
def reset_seating(self):
for row in range(self.rows):
for col in range(self.cols):
self.seats[row][col] = 'O'
self.buttons[row][col].config(text='O', bg='lightgreen')
self.selected_seats.clear()

if __name__ == "__main__":
flight_data = {
'Airline': ['Emirates', 'Etihad', 'Singapore Airlines', 'Qatar Airways', 'Air
India',
'United Airlines', 'British Airways', 'Delta Airlines', 'Lufthansa',
'Turkish Airlines'],
'Flight ID': ['101', '102', '103', '104', '105', '106', '107', '108', '109', '110'],
'Departure Time': ['2024-11-15 08:00', '2024-11-15 09:00', '2024-11-15
10:00',
'2024-11-15 11:00', '2024-11-15 12:00', '2024-11-15 13:00',
'2024-11-15 14:00', '2024-11-15 15:00', '2024-11-15 16:00',
'2024-11-15 17:00'],
'Arrival Time': ['2024-11-15 10:00', '2024-11-15 11:00', '2024-11-15 12:00',
'2024-11-15 13:00', '2024-11-15 14:00', '2024-11-15 15:00',
'2024-11-15 16:00', '2024-11-15 17:00', '2024-11-15 18:00',
'2024-11-15 19:00'],
'Price': [500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400]
}

flights_df = pd.DataFrame(flight_data)
root = tk.Tk()
app = AirlineReservationSystem(root, 5, 4, flights_df)
root.mainloop()

9. Conclusion

The Airline Reservation System successfully demonstrates how to build a user-


friendly flight booking application using Python and Tkinter. The project
showcases key programming concepts such as event-driven programming, GUI
design, and data handling. Future enhancements could include:

- Database integration for persistent data storage.


- Enhanced user authentication for a personalized experience.
- Implementation of additional features such as cancellation and modification
of bookings.

This project serves as a comprehensive introduction to GUI development in


Python and lays the groundwork for more complex applications in the future.

You might also like