0% found this document useful (0 votes)
32 views5 pages

AIR

This document contains Python code for a flight booking system with Tkinter GUI. It includes functions for viewing existing flights from a database, updating flight details, and booking tickets. Key aspects: - Functions defined to view flights by querying a MySQL database and displaying results, update flight status by flight number, and book tickets by entering departure, destination, name, and age. - Tkinter used to create GUI elements like labels, entries, and buttons. - Global variables store entry widget objects and values passed between functions. - Flights checked and passenger details accepted before inserting booking into database.

Uploaded by

Mukesh Kumar
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)
32 views5 pages

AIR

This document contains Python code for a flight booking system with Tkinter GUI. It includes functions for viewing existing flights from a database, updating flight details, and booking tickets. Key aspects: - Functions defined to view flights by querying a MySQL database and displaying results, update flight status by flight number, and book tickets by entering departure, destination, name, and age. - Tkinter used to create GUI elements like labels, entries, and buttons. - Global variables store entry widget objects and values passed between functions. - Flights checked and passenger details accepted before inserting booking into database.

Uploaded by

Mukesh Kumar
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/ 5

import tkinter

from tkinter import ttk

import tkinter as tk

from tkinter import *

Import datetime

from PIL import Image Tk, Image

import mysql.connector

sqlobj = mysql.connector.connect(user= "root", host="localhost", password="1234", database="csgroup")

cur = sqlobj.cursor()

#-------------------------------------------------VIEWING FLIGHTS-----------------------------------------------------------

def viewing_flights():

a = tk.Tk()

a.geometry("2000x2500")

cur.execute("select * from flight ")

i=0

for flight in cur:

for j in range(len(flight));

e = Entry(a, width=10, fg='blue')

e.grid(row=i, column=j)

e.insert(END, flight[j])

1=1+1

a.mainloop()

#----------------------------------------------------UPDATE FLIGHT-----------------------------------------------------------

window1 = False

global u1, u2

def window1():

global u1, u2

window1 = tkinter.Tk()

window1.configure(bg="#FCC9C5")

1|Page
window1.title("Updating details")

u1 = ttk.Entry(window1, width=50)

u1.grid(row=1, column=1)

TitleLabel_1 = ttk.Label(window1, text="Enter Flight no", font="Times")

TitleLabel_1.grid(row=1, column=0)

btn = ttk.Button(window1, text="Submit Answers", command = checking_flight_1)

btn.grid(row=5, column=1)

def checking_flight_1():

global u1, u

u = u1.get()

print(u)

cur.execute("select Flightno from flight where Flightno=%s", (u,))

a = cur.fetchall()

print(a, "naman")

if len(a) == 0:

s1 = tk.Tk()

s1.title("No Flights Found!")

tk.Label(master=s1, text="Enter valid Flightno").grid(row=1, column=1)

else:

info_1()

2|Page
def info_1():

global u2

L = tkinter.Tk()

L.configure(bg="#FCC9C5")

M5 = ttk.Label(L, text="Status", font="Times")

M5.grid(row=3, column=0)

u2= ttk.Entry(L, width=50)

u2.grid(row=3, column=1)

btn = ttk.Button(L, text="Submit Answers", command=add_data_1)

btn.grid(row=7, column=1)

def add_data_1():

global u1, u2

status = u2.get()

Flightno = int(u1.get())

x1 = status

stmt = 'update flight set status="%s" where Flightno = "%5""

s = (x1, Flightno)

cur.execute(stmt, s)

sqlobj.commit()

#--------------------------------------------------FLIGHT BOOKING------------------------------------------------

window2 = False

global e3, e4, e5, еб, е7

3|Page
def window2():

global e3, e4, e5, еб, е7

window2 = tkinter.Tk()

window2.title("Booking tickets")

window2.configure(bg="#FCC9C5")

TitleLabel = ttk.Label(window2, text="Enter depature", font="Times")

TitleLabel.grid(row=1, column=0)

e3 = ttk.Entry(window2, width=50)

e3.grid(row=1, column=1)

L4 = ttk.Label(window2, text="Enter destination", font="Times")

L4.grid(row=2, column=0)

e4 = ttk.Entry(window2, width=50)

e4.grid(row=2, column=1)

btn = ttk.Button(window2, text="Submit Answers", command=checking_flight)

btn.grid(row=5, column=1)

def checking_flight():

global e3, e4

q = e3.get().upper()

w= e4.get().upper()

if q==”MAA” and w==”BOM”:

info()

4|Page
elif q==”LKO" and w==”GOl”

info()

else:

s=tk.Tk()

s.title("No Flights!")

tk.Label(master-s, text="Enter valid data"). grid(row=1, column=1)

def info(): #Accepting passenger details

global e3, e4, е5, еб, е7

a = tkinter.Tk()

a.configure(bg="#FCC9C5")

L5 = ttk.Label(a, text="Name", font="Times")

L5.grid(row=3, column=0)

e5 = ttk.Entry(a, width=50)

e5.grid(row=3, column=1)

L6 = ttk.Label(a, text="Age", font="Times")

L6.grid(row=4, column=0)

5|Page

You might also like