Project Report
Project Report
1. Introduction
2. Objectives
3. Technologies Used
- 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
- 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.
- 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
- 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.
- 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.
- 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 flight data is initialized in the `__main__` block using a Pandas DataFrame,
which is passed to the `AirlineReservationSystem` class.
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.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)
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")
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)
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 not self.selected_seats:
messagebox.showwarning("Warning", "Please select at least one
seat.")
return
self.reset_seating()
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