def populate_window():#...............................................................................................

	#conn = sqlite3.connect('Flight.db')
	conn = db.db_connect()

	if from_airport_global=="all" and to_airport_global=="all":

		sqlcode = "Select * from Flights WHERE Date >= ?" + " ORDER BY " + sort_by_global + " ASC"
		cursor = conn.execute(sqlcode, (cal_selected_date,)).fetchall()

	elif from_airport_global=="all":
		cursor = conn.execute("SELECT * FROM Flights WHERE To_Airport = ? AND Date >= ? ORDER BY "+sort_by_global+" ASC", (to_airport_global, cal_selected_date))

	elif to_airport_global=="all":
		cursor = conn.execute("SELECT * FROM Flights WHERE From_Airport = ? AND Date >= ? ORDER BY "+sort_by_global+" ASC", (from_airport_global, cal_selected_date))
	else:
		cursor = conn.execute("SELECT * FROM Flights WHERE From_Airport = ? AND To_Airport = ? AND DATE >= ? \
						   ORDER BY "+sort_by_global+" ASC", (from_airport_global,to_airport_global, cal_selected_date))

	content = ""

	collected_IDs.clear()

	for row in cursor:
		collected_IDs.add(row[0])

		content = content +"ID:"+ str(row[0]) +"  "+  str(row[1]) +"  "+ str(row[2]) +"  "+ str(row[3]) +"  "+ str(row[4])  \
					  	  +"  "+  str(row[5]) +"  "+ str(row[6]) +"  "+ str(row[7]) +"  "+ str(row[8]) + " " + '\n'
	conn.close()

	print(content)
	print(len(collected_IDs))

	return content
def fetch_one_record(
    flight_numb, label, cancel_Btn
):  #..................................................................

    #sqlite_file = 'Flight.db'
    table_name = 'Flights'
    #conn = sqlite3.connect(sqlite_file)
    conn = db.db_connect()
    cursor = conn.cursor()

    # cursor.execute("SELECT Flight_ID FROM Flights WHERE Flight_ID = ?", (flight_numb,))
    cursor.execute("SELECT * FROM Flights WHERE Flight_ID = ?",
                   (flight_numb, ))
    data = cursor.fetchall()  # data=cursor.fetchone()
    if len(data) == 0:
        label.config(text="Flight ID: " + str(flight_numb) + " Does Not Exist")
    else:
        flight = "Flight ID:" + str(data[0][0]) + "  " + str(data[0][2]) + "  "

        time = str(data[0][3])
        if time.endswith(':00'):
            time = time[:-3]

        flight = flight + time +"  "+ "from:"+str(data[0][4]) +"  to:"+str(data[0][5]) +"  seats:"+str(data[0][6]) \
                  +"  fare:$"+str(data[0][7])  +"  status:"+str(data[0][8])

        label.config(text=flight)

        cancel_Btn.config(state='normal')
        cancel_Btn.config(text="Cancel Flight")

        btn_visibility_toggle(cancel_Btn, True)
def get_table_colNames():#............................................................................................

	#sqlite_file = 'Flight.db'
	table_name = 'Flights'
	conn = db.db_connect()
	c = conn.cursor()
	c.execute('PRAGMA TABLE_INFO({})'.format(table_name))
	# collect names in a list
	names = [tup[1] for tup in c.fetchall()]

	conn.close()

	return names
def populate_airline_admin_gui(
        comments, welcome_label,
        user):  #......................................................

    welcome_label.config(text=str('Welcome ' + user.capitalize() +
                                  ' here are ALL existing reservations:'))

    conn = db.db_connect()

    collected_IDs.clear()

    # sqlcode = "SELECT FLIGHTS.FLIGHT_ID, USERNAME, DATE, TIME, FROM_AIRPORT, TO_AIRPORT, STATUS FROM FLIGHTS_BOOKED INNER JOIN FLIGHTS WHERE FLIGHTS_BOOKED.Flight_ID = FLIGHTS.Flight_ID"
    sqlcode = "SELECT * FROM FLIGHTS INNER JOIN CUST_FLIGHT WHERE CUST_FLIGHT.Flight_ID = FLIGHTS.Flight_ID"
    cursor = conn.execute(sqlcode).fetchall()

    comments.delete(1.0, tk.END)

    content = ""
    for row in cursor:
        collected_IDs.add(row[0])

        content = content + "ID:" + str(row[0]) + "  " + str(
            row[1]) + "  " + str(row[2]) + "  "

        time = str(row[3])
        if time.endswith(':00'):
            time = time[:-3]

        content = content + time +"  "+  str(row[4]) +"  "+ str(row[5]) +"  "+ str(row[6]) +"  "+ str(row[7]) \
                  +"  "+ str(row[8]) +"  "+ str(row[9]) +"  "+ str(row[11]) + " " + '\n'

        comments.insert(tk.END, content)

    # --- Create FLIGHT BUTTON widget ---
    create_flight_Btn = Button(r_window,
                               width=20,
                               text='Create New Flight',
                               fg=css.color_text,
                               bg=css.color_btn,
                               relief='ridge')
    create_flight_Btn.config(highlightbackground=css.color_bg_newSession)
    create_flight_Btn.config(font=("Helvetica", 18, "bold"))
    create_flight_Btn.config(
        bd=8, relief='raised')  # flat, groove, raised, ridge, solid, or sunken
    create_flight_Btn.place(x=(css.frame_width + 140) / 2,
                            y=490,
                            anchor='center')
    create_flight_Btn.config(command=lambda: create_NEW_Flight(user))

    conn.close()
def polulate_Inbound(
    origin
):  #............................................................................

    #conn = sqlite3.connect('Flight.db')

    #cursor = conn.execute("SELECT * FROM Flights")
    conn = db.db_connect()
    cursor = conn.execute("SELECT * FROM Flights WHERE To_Airport = ?",
                          (origin, ))

    content = ""

    for row in cursor:
        content = content +"ID:"+ str(row[0]) +"  "+  str(row[1]) +"  "+ str(row[2]) +"  "+ str(row[3]) +"  "+ str(row[4])  \
                +"  "+  str(row[5]) +"  "+ str(row[6]) +"  "+ str(row[7]) +"  "+ '\n'
    conn.close()
    return content
Ejemplo n.º 6
0
def populate_window(
    value
):  # .........................................................................................

    conn = db.db_connect()
    sqlcode = "SELECT * FROM FLIGHTS WHERE Airline_Name = ?"

    cursor = conn.execute(sqlcode, (value, ))

    content = ""

    for row in cursor:
        collected_IDs.add(row[0])

        content = content + "ID:" + str(row[0]) + "  " + str(row[1]) + "  " + str(row[2]) + "  " + str(
            row[3]) + "  " + str(row[4]) \
                  + "  " + str(row[5]) + "  " + str(row[6]) + "  " + str(row[7]) + "  " + str(
            row[8]) + "  " + "  " + '\n'
    conn.close()
    return content
def populate_search_engine_admin_gui(
        comments, cancelbutton
):  #.........................................................

    conn = db.db_connect()

    collected_IDs.clear()

    sqlcode = "SELECT * FROM FLIGHTS INNER JOIN CUST_FLIGHT ON FLIGHTS.FLIGHT_ID = CUST_FLIGHT.Flight_ID WHERE METHOD =?"

    se = "SEARCH_ENGINE"
    cursor = conn.execute(sqlcode, (se, )).fetchall()

    for row in cursor:
        collected_IDs.add(row[0])

        reservations = str(row[0]) + " " + str(row[1]) + " " + str(
            row[2]) + " " + str(row[3]) + " " + str(row[4]) + " " + str(
                row[5]) + " " + str(row[6]) + " " + str(row[7]) + " " + str(
                    row[8]) + " " + str(row[9]) + " " + str(row[11]) + '\n'
        comments.insert(tk.END, reservations)

    conn.close()
def populate_customer_reservations_gui(
        comments, username
):  #...........................................................

    conn = db.db_connect()
    collected_IDs.clear()

    sqlcode = "SELECT * FROM FLIGHTS INNER JOIN CUST_FLIGHT ON FLIGHTS.Flight_ID = CUST_FLIGHT.Flight_ID WHERE CUST_FLIGHT.USERNAME = ?"

    cursor = conn.execute(sqlcode, (username, )).fetchall()
    comments.delete(1.0, tk.END)

    for row in cursor:
        collected_IDs.add(row[0])

        reservations = str(row[0]) + " " + str(row[1]) + " " + str(
            row[2]) + " " + str(row[3]) + " " + str(row[4]) + " " + str(
                row[5]) + " " + str(row[6]) + " " + str(row[7]) + " " + str(
                    row[8]) + " " + str(row[9]) + " " + str(row[11]) + '\n'
        comments.insert(tk.END, reservations)

    conn.close()

    # --- CANCEL FLIGHT BUTTON widget ---
    cancel_Btn = Button(r_window,
                        width=15,
                        text='Cancel Flight',
                        fg=css.color_text,
                        bg=css.color_btn,
                        relief='ridge')
    cancel_Btn.config(highlightbackground=css.color_bg_newSession)
    cancel_Btn.config(font=("Helvetica", 20, "bold"))
    cancel_Btn.config(
        bd=8, relief='raised')  # flat, groove, raised, ridge, solid, or sunken
    cancel_Btn.config(
        command=lambda: btn_click_cancelFlight(cancel_Btn)
    )  # calls btn_click_saveCurrentDate() when the button is clicked
Ejemplo n.º 9
0
import DB_UTIL as db
#import numpy as np

con = db.db_connect()

#"""
#Here, I simply test the functionality of the DB. Give it a shot
db.create_flights('MANEMARS', '3030-30-30', '22:30:30', 'Area51', 'MarsRover', 1, 0, 'ON-TIME')
a = db.get_Flights('To_Airport')
print(a)

#db.queryexec("DELETE FROM Cust_Flight;")
#con.commit()

#print(db.book_a_flight('paul', 1, 'GUI'))
#print(db.book_a_flight('paul', 420, 'SEARCH'))
db.cancel_flight_admin(420)

#Now check reservations
print('\n\n')
print(db.get_full_user_reservation('paul'))

db.cancel_reservation_passenger('paul', 420)
print(db.get_full_user_reservation('paul'))

#"""
#Lets test my new work here
#for i in range(1, 10):
#print(db.get_user_reservation('paul'))
#flight_from_jfk = db.queryexec("SELECT * FROM Flights WHERE From_Airport = 'KJFK-New York' ORDER BY Airline_Name ASC")
#print(flight_from_jfk)
Ejemplo n.º 10
0
    ('lufthansa', '2019-12-13', '10:50:00', 'JFK', 'JKT', 150, 500, 'Avail'), 
    ('finnair', '2019-12-19', '05:50:00', 'JFK', 'JKT', 150, 500, 'Avail'),
    ('aeromexico', '2019-12-18', '02:50:00', 'MAM', 'MEM', 150, 500, 'Avail'),
    ('quantas', '2019-12-20', '06:50:00', 'MARS', 'JUPITER', 150, 500, 'Avail'),
    ('british airways', '2019-12-12', '09:50:00', 'HOOVERDAM', 'AREA51', 150, 500, 'Booked')    
)

"""
Perhaps we can figure out a way to create a huge amount of these tuples and store in a file, then choose stuff randomly.
We can make this happen, pretty easily.
Now, we need to add these to the DB. LETS BEGIN
"""

import DB_UTIL
import randdata as rd
conobj = DB_UTIL.db_connect() #Connect to the DB

#So now that we're connected, lets start adding things.

#for i in range(0, len(customers)):
#    DB_UTIL.create_customer(conobj, customers[i])

for i in range(0, len(rd.airports)):
    DB_UTIL.create_airports(rd.airports[i][0], rd.airports[i][1], rd.airports[i][2])

for i in range(0, len(rd.airlines)):
    DB_UTIL.create_airlines(rd.airlines[i])

for i in range(0, len(rd.flights)):
    DB_UTIL.create_flights(rd.flights[i][0], rd.flights[i][1], rd.flights[i][2], rd.flights[i][3], rd.flights[i][4], rd.flights[i][5], rd.flights[i][6], rd.flights[i][7])
Ejemplo n.º 11
0
def init(
):  # .......................................................................................................

    print(get_table_colNames())

    # -- GETTING THE DATE HERE THAT'S ALL
    with open('entered_data.txt', 'r') as text:  # create an output text file
        for line in text:
            entry = line

    items = line.split()

    entered_day = int(items[0].strip(
    ))  # remove whitespace characters i.e. '\n' at the start/end
    entered_mon = int(items[1].strip())
    entered_year = int(items[2].strip())
    date = datetime.datetime(entered_year, entered_mon,
                             entered_day)  # year , month , day
    cal_selected_date = str(date.date())

    a_window.title('Airlines')  # Main window title
    x_screen = (a_window.winfo_screenwidth() // 2) - (css.frame_center_W)
    y_screen = (a_window.winfo_screenheight() // 2) - (css.frame_center_H)

    width = css.frame_width + 80

    a_window.geometry(
        "{}x{}+{}+{}".format(width, css.frame_hight, x_screen,
                             y_screen))  # Main window size & position
    a_window.config(bg=css.color_bg_newSession)
    a_window.resizable(False, False)

    x = 120

    # HERE IS CODE FOR THE IMAGE. USE SUITABLE IMAGE ANG FILENAME HERE PLEASE
    logo1 = PhotoImage(file='airlines.png')
    l_logo = Label(a_window, image=logo1, bg=css.color_bg_currentDate)
    l_logo.image = logo1
    l_logo.place(x=width / 2, y=10, anchor='n')

    a_window.protocol("WM_DELETE_WINDOW", on_closing)

    # HERE IS THE CODE FOR THE ADMIN BUTTON
    # --- LOG-IN BUTTON widget ---
    login_Btn = Button(a_window,
                       width=10,
                       text='admin',
                       fg=css.color_text,
                       bg=css.color_btn)
    login_Btn.config(highlightbackground=css.color_bg_newSession)
    login_Btn.config(font=("Helvetica", 15, "bold"))
    login_Btn.config(
        bd=8, relief='raised')  # flat, groove, raised, ridge, solid, or sunken
    login_Btn.config(command=btn_click_LogIn
                     )  # calls btn_click_LogIn() when the button is clicked
    login_Btn.place(x=120, y=26, anchor='center')

    # HERE IS THE CODE FOR DISPLAY LABEL
    label_1 = Label(a_window,
                    width=60,
                    text='',
                    fg=css.color_text,
                    bg=css.color_bg_newSession)
    label_1.place(x=css.frame_center_W, y=128 + x, anchor='center')
    label_1.config(font=(
        "Helvetica", 18,
        "normal"))  # normal, bold, roman, italic, underline, and overstrike
    label_1.config(text=str('AVAILABLE FLIGHTS FOR YOUR SELECTED AIRLINE'))

    # CONNECT TO DATABASE AND UPDATE THE AIRLINE LIST
    # conn = sqlite3.connect('Flight.db');

    conn = db.db_connect()

    sqlcode = "SELECT AIRLINENAME FROM AIRLINES"
    cursor = conn.execute(sqlcode).fetchall()
    airline_option_List = []
    for row in cursor:
        airline_option_List.append(row[0])
    conn.close()

    variable1 = StringVar(a_window)
    variable1.set("AIRLINES")  # default value
    from_airport = OptionMenu(a_window,
                              variable1,
                              *airline_option_List,
                              command=from_selection)
    from_airport.config(font=("Helvetica", 16))
    from_airport.config(bg=css.color_bg_newSession,
                        width=15,
                        fg=css.color_text)
    from_airport.place(x=120, y=52, anchor='center')

    # --- RESULTS TEXT BOX widget ---
    global results
    results = Text(a_window,
                   width=90,
                   height=12,
                   fg=css.color_text,
                   bg=css.color_bg_reservations,
                   yscrollcommand=set())
    results.config(font=("Helvetica", 15, "normal"))
    results.config(state=NORMAL)
    results.place(x=width / 2, y=244 + x, anchor='center')
    results.insert(END, "RESULTS HERE")
    results.configure(state='disabled')

    # --- ENTER FLIGHT ID widget ---
    label_2 = Label(a_window,
                    width=20,
                    text='',
                    fg=css.color_text,
                    bg=css.color_bg_newSession)
    label_2.place(x=css.frame_center_W - 60, y=380 + x, anchor='center')
    label_2.config(font=(
        "Helvetica", 20,
        "normal"))  # normal, bold, roman, italic, underline, and overstrike
    label_2.config(text=str('Enter Flight ID'))

    # --- FLIGHT ID ENTRY widget ---
    entry_ID = Entry(a_window,
                     show=None,
                     width=5,
                     bg='#FFFFFF',
                     fg=css.color_placeholder,
                     exportselection=0,
                     justify='center')
    entry_ID.config(font=("Helvetica", 20, "normal"))
    entry_ID.bind('<Return>', lambda args: enter_keyboardkKey(entry_ID))
    # entry_ID.bind('<KeyRelease>', lambda args: enter_keyboardkKey(entry_ID) ) # for dynamic realtime feedback capture
    entry_ID.bind("<FocusIn>", lambda args: entry_ID_click(entry_ID))
    entry_ID.bind("<FocusOut>",
                  lambda args: entry_ID_check(entry_ID, label_3, book_Btn))
    entry_ID.insert(0, '0')
    entry_ID.place(x=css.frame_center_W + 48, y=380 + x,
                   anchor='center')  # alternative to entry_ID.pack()
    # entry_ID.focus_set() # to automatically focus on the widget at start up

    # --- SELECTED FLIGHT ID widget ---
    label_3 = Label(a_window,
                    width=110,
                    text='',
                    fg=css.color_text,
                    bg=css.color_bg_newSession)
    label_3.place(x=width / 2, y=420 + x, anchor='center')
    label_3.config(font=(
        "Helvetica", 16,
        "normal"))  # normal, bold, roman, italic, underline, and overstrike
    label_3.config(text='')

    # --- BOOK FLIGHT BUTTON widget ---
    book_Btn = Button(a_window,
                      width=15,
                      text='Book Flight',
                      fg=css.color_text,
                      bg=css.color_btn,
                      relief='ridge')
    book_Btn.config(highlightbackground=css.color_bg_newSession)
    book_Btn.config(font=("Helvetica", 20, "bold"))
    book_Btn.config(
        bd=8, relief='raised')  # flat, groove, raised, ridge, solid, or sunken
    book_Btn.config(command=lambda: btn_click_bookFlight(label_3, book_Btn))

    # --- LOGGED IN USER LABEL widget ---
    label_user = Label(a_window,
                       width=15,
                       text='',
                       fg=css.color_text,
                       bg=css.color_bg_newSession)
    label_user.place(x=width - 140, y=26, anchor='center')
    label_user.config(font=(
        "Helvetica", 16,
        "bold"))  # normal, bold, roman, italic, underline, and overstrike
    label_user.config(text=str("user: " + css.global_user))

    btn_visibility_toggle(book_Btn, False)
Ejemplo n.º 12
0
def init(
):  #...............................................................................

    ap_window.title('Airports')  #Main window title
    x_screen = (ap_window.winfo_screenwidth() // 2) - (css.frame_center_W)
    y_screen = (ap_window.winfo_screenheight() // 2) - (css.frame_center_H)

    ap_window.geometry(
        "{}x{}+{}+{}".format(css.frame_width, css.frame_hight, x_screen,
                             y_screen))  #Main window size & position
    ap_window.config(bg=css.color_bg_newSession)
    ap_window.resizable(False, False)

    x = 120

    image = PhotoImage(file='airport.png')
    l_logo = Label(ap_window, image=image, bg=css.color_bg_currentDate)
    l_logo.image = image
    l_logo.place(x=css.frame_center_W, y=15 + x, anchor='center')

    # --- WELCOME INSTRUCTIONS LABEL widget ---
    label_1 = Label(ap_window,
                    width=60,
                    text='',
                    fg=css.color_text,
                    bg=css.color_bg_newSession)
    label_1.place(x=css.frame_center_W, y=170 + x, anchor='center')
    label_1.config(font=(
        "Helvetica", 20,
        "normal"))  # normal, bold, roman, italic, underline, and overstrike
    label_1.config(text=str('Welcome traveler, please select your airport'))

    # --- SELECT FROM AIRPORT OPTION MENU widget ---
    #CONNECT TO DATABASE AND UPDATE THE FLIGHT LIST
    #conn = sqlite3.connect('Flight.db');

    conn = db.db_connect()

    sqlcode = "SELECT AIRPORTNAME FROM AIRPORTS"
    cursor = conn.execute(sqlcode).fetchall()
    from_option_List = []
    for row in cursor:
        from_option_List.append(row[0])
    conn.close()
    #from_option_List = ["all", "JFK", "LAG", "LAX", "DC", "DUB", "DFW"]	##### this must be populated from the SQLite3

    ##### NEED THIS FUNCTION ################################################
    #PLEASE hardcode "all" as the 1st menu option
    #from_option_List = get_FROM_Airports()
    #########################################################################

    variable1 = StringVar(ap_window)
    variable1.set("FROM AIRPORT")  # default value
    from_airport = OptionMenu(ap_window,
                              variable1,
                              *from_option_List,
                              command=from_selection)
    from_airport.config(font=("Helvetica", 17))
    from_airport.config(bg=css.color_bg_newSession,
                        width=20,
                        fg=css.color_text)
    from_airport.place(x=css.frame_center_W - 130, y=208 + x, anchor='center')

    # --- SELECT TO AIRPORT OPTION MENU widget ---
    # CONNECT TO DATABASE AND UPDATE THE FLIGHT LIST
    #conn = sqlite3.connect('Flight.db');

    conn = db.db_connect()
    sqlcode = "SELECT AIRPORTNAME FROM AIRPORTS"
    cursor = conn.execute(sqlcode).fetchall()
    to_option_List = []
    for row in cursor:
        to_option_List.append(row[0])
    conn.close()
    #to_option_List = ["all", "JFK", "LAG", "LAX", "DC", "DUB", "DFW"]	##### this must be populated from the SQLite3

    ##### NEED THIS FUNCTION ################################################
    #PLEASE hardcode "all" as the 1st menu option
    #to_option_List = get_TO_Airports()
    #########################################################################

    variable2 = StringVar(ap_window)
    variable2.set("TO AIRPORT")
    to_airport = OptionMenu(ap_window,
                            variable2,
                            *to_option_List,
                            command=to_selection)
    to_airport.config(font=("Helvetica", 17))
    to_airport.config(bg=css.color_bg_newSession, width=20, fg=css.color_text)
    to_airport.place(x=css.frame_center_W + 130, y=208 + x, anchor='center')

    # --- Current Date LABEL widget
    label_date = Label(ap_window,
                       width=30,
                       text='',
                       fg=css.color_text,
                       bg=css.color_bg_newSession)
    label_date.place(x=css.frame_center_W, y=610, anchor='center')
    label_date.config(font=(
        "Helvetica", 20,
        "normal"))  # normal, bold, roman, italic, underline, and overstrike
    label_date.config(text=str(css.show_date))  # display the entered date
    # -------------------------------------------------------

    ap_window.protocol("WM_DELETE_WINDOW", on_closing)
def init(
    admin_name, parent
):  #............................................................................................

    f_window.title('Create New Flight')  #Main window title
    x_screen = (f_window.winfo_screenwidth() // 2) - (css.frame_center_W)
    y_screen = (f_window.winfo_screenheight() // 2) - (css.frame_center_H)

    width = css.frame_width + 140

    f_window.geometry(
        "{}x{}+{}+{}".format(width, css.frame_hight, x_screen,
                             y_screen))  #Main window size & position
    f_window.config(bg=css.color_bg_newSession)
    f_window.resizable(False, False)

    #--- SAVE BUTTON DECLARED HERE
    save_Btn = tk.Button(f_window,
                         width=20,
                         text='Create Flight',
                         fg=css.color_text,
                         bg=css.color_btn,
                         relief='ridge')
    save_Btn.config(highlightbackground=css.color_bg_newSession)
    save_Btn.config(font=("Helvetica", 18, "bold"))
    save_Btn.config(
        bd=8, relief='raised')  # flat, groove, raised, ridge, solid, or sunken
    save_Btn.config(command=lambda: btn_click_saveFlight(save_Btn, admin_name))

    # --- AIRLINE NAME ENTRY widget ---
    airline_Name = tk.Entry(f_window,
                            show=None,
                            width=25,
                            bg="#FFFFFF",
                            fg=css.color_placeholder,
                            exportselection=0,
                            justify='center')
    airline_Name.config(font=("Helvetica", 20, "bold"))
    airline_Name.bind("<FocusIn>",
                      lambda args: entry_click('Airline Name', airline_Name))
    airline_Name.bind(
        "<FocusOut>",
        lambda args: entry_check('Airline Name', airline_Name, save_Btn))
    airline_Name.insert(0, 'Airline Name')
    airline_Name.bind('<Return>',
                      lambda args: enter_keyboardkKey(airline_Name))
    airline_Name.place(x=width / 2, y=50, anchor='n')

    # --- FROM AIRPORT widget ---
    from_Airport = tk.Entry(f_window,
                            show=None,
                            width=25,
                            bg="#FFFFFF",
                            fg=css.color_placeholder,
                            exportselection=0,
                            justify='center')
    from_Airport.config(font=("Helvetica", 20, "bold"))
    from_Airport.bind("<FocusIn>",
                      lambda args: entry_click('From Airport', from_Airport))
    from_Airport.bind(
        "<FocusOut>",
        lambda args: entry_check('From Airport', from_Airport, save_Btn))
    from_Airport.insert(0, 'From Airport')
    from_Airport.bind('<Return>',
                      lambda args: enter_keyboardkKey(from_Airport))
    from_Airport.place(x=width / 2, y=100, anchor='n')

    # --- TO AIRPORT ENTRY widget ---
    to_Airport = tk.Entry(f_window,
                          show=None,
                          width=25,
                          bg="#FFFFFF",
                          fg=css.color_placeholder,
                          exportselection=0,
                          justify='center')
    to_Airport.config(font=("Helvetica", 20, "bold"))
    to_Airport.bind("<FocusIn>",
                    lambda args: entry_click('To Airport', to_Airport))
    to_Airport.bind(
        "<FocusOut>",
        lambda args: entry_check('To Airport', to_Airport, save_Btn))
    to_Airport.insert(0, 'To Airport')
    to_Airport.bind('<Return>', lambda args: enter_keyboardkKey(to_Airport))
    to_Airport.place(x=width / 2, y=150, anchor='n')

    # --- TIME ENTRY widget ---
    time_entry = tk.Entry(f_window,
                          show=None,
                          width=25,
                          bg="#FFFFFF",
                          fg=css.color_placeholder,
                          exportselection=0,
                          justify='center')
    time_entry.config(font=("Helvetica", 20, "bold"))
    time_entry.bind("<FocusIn>",
                    lambda args: entry_click('Departure Time', time_entry))
    time_entry.bind(
        "<FocusOut>",
        lambda args: entry_check('Departure Time', time_entry, save_Btn))
    time_entry.insert(0, 'Departure Time')
    time_entry.bind('<Return>', lambda args: enter_keyboardkKey(time_entry))
    time_entry.place(x=width / 2, y=200, anchor='n')

    # --- Day ENTRY widget ---
    day_entry = tk.Entry(f_window,
                         show=None,
                         width=25,
                         bg="#FFFFFF",
                         fg=css.color_placeholder,
                         exportselection=0,
                         justify='center')
    day_entry.config(font=("Helvetica", 20, "bold"))
    day_entry.bind("<FocusIn>", lambda args: entry_click('day', day_entry))
    day_entry.bind("<FocusOut>",
                   lambda args: entry_check('day', day_entry, save_Btn))
    day_entry.insert(0, 'day')
    day_entry.bind('<Return>', lambda args: enter_keyboardkKey(day_entry))
    day_entry.place(x=width / 2, y=250, anchor='n')

    # --- Month ENTRY widget ---
    mon_entry = tk.Entry(f_window,
                         show=None,
                         width=25,
                         bg="#FFFFFF",
                         fg=css.color_placeholder,
                         exportselection=0,
                         justify='center')
    mon_entry.config(font=("Helvetica", 20, "bold"))
    mon_entry.bind("<FocusIn>", lambda args: entry_click('mon', mon_entry))
    mon_entry.bind("<FocusOut>",
                   lambda args: entry_check('mon', mon_entry, save_Btn))
    mon_entry.insert(0, 'month')
    mon_entry.bind('<Return>', lambda args: enter_keyboardkKey(mon_entry))
    mon_entry.place(x=width / 2, y=300, anchor='n')

    # --- Year ENTRY widget ---
    year_entry = tk.Entry(f_window,
                          show=None,
                          width=25,
                          bg="#FFFFFF",
                          fg=css.color_placeholder,
                          exportselection=0,
                          justify='center')
    year_entry.config(font=("Helvetica", 20, "bold"))
    year_entry.bind("<FocusIn>", lambda args: entry_click('year', year_entry))
    year_entry.bind("<FocusOut>",
                    lambda args: entry_check('year', year_entry, save_Btn))
    year_entry.insert(0, 'year')
    year_entry.bind('<Return>', lambda args: enter_keyboardkKey(year_entry))
    year_entry.place(x=width / 2, y=350, anchor='n')

    # --- Fare ENTRY widget ---
    fare_entry = tk.Entry(f_window,
                          show=None,
                          width=25,
                          bg="#FFFFFF",
                          fg=css.color_placeholder,
                          exportselection=0,
                          justify='center')
    fare_entry.config(font=("Helvetica", 20, "bold"))
    fare_entry.bind("<FocusIn>", lambda args: entry_click('Fare', fare_entry))
    fare_entry.bind("<FocusOut>",
                    lambda args: entry_check('Fare', fare_entry, save_Btn))
    fare_entry.insert(0, 'Fare')
    fare_entry.bind('<Return>', lambda args: enter_keyboardkKey(fare_entry))
    fare_entry.place(x=width / 2, y=400, anchor='n')

    # --- Capacity ENTRY widget ---
    capacity_entry = tk.Entry(f_window,
                              show=None,
                              width=25,
                              bg="#FFFFFF",
                              fg=css.color_placeholder,
                              exportselection=0,
                              justify='center')
    capacity_entry.config(font=("Helvetica", 20, "bold"))
    capacity_entry.bind("<FocusIn>",
                        lambda args: entry_click('Capacity', capacity_entry))
    capacity_entry.bind(
        "<FocusOut>",
        lambda args: entry_check('Capacity', capacity_entry, save_Btn))
    capacity_entry.insert(0, 'Capacity')
    capacity_entry.bind('<Return>',
                        lambda args: enter_keyboardkKey(capacity_entry))
    capacity_entry.place(x=width / 2, y=450, anchor='n')

    conn = db.db_connect()
    sqlcode = "SELECT AIRPORTNAME FROM AIRPORTS"
    cursor = conn.execute(sqlcode).fetchall()
    from_option_List = []
    for row in cursor:
        from_option_List.append(row[0])
    conn.close()

    from_option_List.insert(0, 'all')

    variable1 = tk.StringVar(f_window)
    variable1.set("FROM")  # default value
    from_airport = tk.OptionMenu(f_window,
                                 variable1,
                                 *from_option_List,
                                 command=from_selection)
    from_airport.config(font=("Helvetica", 15))
    from_airport.config(bg=css.color_bg_newSession,
                        width=12,
                        fg=css.color_text)
    from_airport.place(x=width / 3 - 100, y=100, anchor='n')

    conn = db.db_connect()
    sqlcode = "SELECT AIRPORTNAME FROM AIRPORTS"
    cursor = conn.execute(sqlcode).fetchall()
    to_option_List = []
    for row in cursor:
        to_option_List.append(row[0])
    conn.close()

    to_option_List.insert(0, 'all')

    variable1 = tk.StringVar(f_window)
    variable1.set("TO")  # default value
    to_airport = tk.OptionMenu(f_window,
                               variable1,
                               *to_option_List,
                               command=to_selection)
    to_airport.config(font=("Helvetica", 15))
    to_airport.config(bg=css.color_bg_newSession, width=12, fg=css.color_text)
    to_airport.place(x=width / 3 - 100, y=150, anchor='n')

    conn = db.db_connect()
    sqlcode = "SELECT AIRLINENAME FROM AIRLINES"
    cursor = conn.execute(sqlcode).fetchall()
    airline_option_List = []
    for row in cursor:
        airline_option_List.append(row[0])
    conn.close()

    airline_option_List.insert(0, 'all')

    variable1 = tk.StringVar(f_window)
    variable1.set("AIRLINES")  # default value
    from_airport = tk.OptionMenu(f_window,
                                 variable1,
                                 *airline_option_List,
                                 command=airline_selection)
    from_airport.config(font=("Helvetica", 15))
    from_airport.config(bg=css.color_bg_newSession,
                        width=12,
                        fg=css.color_text)
    from_airport.place(x=width / 3 - 100, y=50, anchor='n')

    f_window.protocol("WM_DELETE_WINDOW", on_closing)
def init():#..........................................................................................................

	#-- GETTING THE DATE HERE THAT'S ALL
	with open('entered_data.txt', 'r') as text:  # create an output text file
		for line in text:
			entry = line

	items = line.split()

	entered_day = int(items[0].strip())  # remove whitespace characters i.e. '\n' at the start/end
	entered_mon = int(items[1].strip())
	entered_year = int(items[2].strip())
	date = datetime.datetime(entered_year, entered_mon, entered_day)  # year , month , day
	cal_selected_date = str(date.date())


	# -- MAKING GUI

	se_window.title('Search Engine')    	#Main window title
	x_screen = (se_window.winfo_screenwidth() // 2) - (css.frame_center_W)
	y_screen = (se_window.winfo_screenheight() // 2) - (css.frame_center_H) - 140

	width = css.frame_width + 140


	se_window.geometry("{}x{}+{}+{}".format( width , 970 , x_screen , y_screen ))	#Main window size & position
	se_window.config(bg=css.color_bg_newSession)
	se_window.resizable(False,False)

	x=120

	logo1 = PhotoImage(file = 'se.png')
	l_logo = Label(se_window, image=logo1, bg=css.color_bg_currentDate)
	l_logo.image = logo1
	l_logo.place(x=width/2, y = 15+x, anchor='center')

	# --- WELCOME INSTRUCTIONS LABEL widget ---
	label_1 = Label( se_window , width=60 , text='' , fg=css.color_text , bg=css.color_bg_newSession )
	label_1.place( x=width/2 , y=160+x , anchor='center' )
	label_1.config( font=( "Helvetica", 20 , "normal" ) )	# normal, bold, roman, italic, underline, and overstrike
	label_1.config( text=str('Please select the airports and date, then click search') )


	# --- SELECT FROM AIRPORT OPTION MENU widget ---
	#CONNECT TO DATABASE AND UPDATE THE FLIGHT LIST
	#conn = sqlite3.connect('Flight.db');

	conn = db.db_connect()
	sqlcode = "SELECT AIRPORTNAME FROM AIRPORTS"
	cursor = conn.execute(sqlcode).fetchall()
	from_option_List = []
	for row in cursor:
		from_option_List.append(row[0])
	conn.close()
	#from_option_List = ["all", "JFK", "LAG", "LAX", "DC", "DUB", "DFW"]	##### this must be populated from the SQLite3

	##### NEED THIS FUNCTION ################################################
	#PLEASE hardcode "all" as the 1st menu option
	#from_option_List = get_FROM_Airports()
	#########################################################################
	from_option_List.insert(0,'all')

	variable1 = StringVar(se_window)
	variable1.set("FROM")  # default value
	from_airport = OptionMenu(se_window, variable1, *from_option_List , command=from_selection )
	from_airport.config( font=( "Helvetica", 15 ) )
	from_airport.config( bg=css.color_bg_newSession , width=12 , fg=css.color_text)
	from_airport.place(x=width/3-15, y=200+x, anchor='center')


	# --- SELECT TO AIRPORT OPTION MENU widget ---
	# CONNECT TO DATABASE AND UPDATE THE FLIGHT LIST
	#conn = sqlite3.connect('Flight.db');

	conn = db.db_connect()
	sqlcode = "SELECT AIRPORTNAME FROM AIRPORTS"
	cursor = conn.execute(sqlcode).fetchall()
	to_option_List = []
	for row in cursor:
		to_option_List.append(row[0])
	conn.close()
	#to_option_List = ["all", "JFK", "LAG", "LAX", "DC", "DUB", "DFW"]	##### this must be populated from the SQLite3

	##### NEED THIS FUNCTION ################################################
	#PLEASE hardcode "all" as the 1st menu option
	#to_option_List = get_TO_Airports()
	#########################################################################
	to_option_List.insert(0,'all')

	variable2 = StringVar(se_window)
	variable2.set("TO")
	to_airport = OptionMenu(se_window, variable2, *to_option_List , command=to_selection )
	to_airport.config( font=( "Helvetica", 15 ) )
	to_airport.config( bg=css.color_bg_newSession , width=12 , fg=css.color_text)
	to_airport.place(x=width/2, y=200+x, anchor='center')


	# --- SELECT SORTING OPTION MENU widget ---
	flights_table_names = get_table_colNames() ;
	sort_option_List = flights_table_names #e.g. sort_option_List = ["Airline_ID", "From_Airport" , "To_Airport" , "Airline" ]
	variable3 = StringVar(se_window)
	variable3.set("SORT BY")
	sort = OptionMenu(se_window, variable3, *sort_option_List , command=sort_selection  )
	sort.config( font=( "Helvetica", 15 ) )
	sort.config( bg=css.color_bg_newSession , width=12 , fg=css.color_text)
	sort.place(x=width-(width/3)+15, y=200+x, anchor='center')


	# CALENDAR SECTION ..................................................
	cal = Calendar(se_window,
				   font="Arial 14", selectmode='day',
				   year=entered_year, month=entered_mon, day=entered_day, showweeknumbers=False, mindate= date)


	# style = ttk.Style(cal)
	# style.theme_use('calm')
	cal.place(x = width/2, y=320+x, anchor='center')


	results = Text(se_window, width=90, height=10, fg=css.color_text, bg=css.color_bg_reservations, yscrollcommand = set())
	results.config(font=("Helvetica", 16, "normal"))
	results.config(state=NORMAL)
	results.place(x=width/2, y=575 + x, anchor='center')
	results.insert(END,"RESULTS WILL PRINT HERE")
	results.configure(state='disabled')

	def calendar_select():
		global cal_selected_date
		cal_selected_date = str(cal.selection_get())
		print(cal_selected_date)

	def print_search_results(): # MAKES THE SEARCH RESULTS AND ADDS IT TO THE MAIN GUI WINDOW
		calendar_select()
		content = populate_window()
		results.config(state=NORMAL)
		results.delete('1.0', END)
		results.insert(END,content)
		results.configure(state='disabled')	
		book_Btn.config(text='Book Flight')
		book_Btn.config(state='normal')		# must be active, disabled, or normal
	# END CALENDAR SECTION .............................................


	# --- ENTER FLIGHT ID widget
	label_2 = Label( se_window , width=20 , text='' , fg=css.color_text , bg=css.color_bg_newSession )
	label_2.place( x=(width/2)-60 , y=706+x , anchor='center' )
	label_2.config( font=( "Helvetica", 20 , "normal" ) )	# normal, bold, roman, italic, underline, and overstrike
	label_2.config( text=str('Enter Flight ID') )


	# --- FLIGHT ID ENTRY widget ---
	entry_ID = Entry( se_window, show=None, width=5, bg='#FFFFFF', fg=css.color_placeholder, exportselection=0, justify='center')
	entry_ID.config( font=( "Helvetica", 20 , "normal" ) )
	entry_ID.bind('<Return>', lambda args: enter_keyboardkKey(entry_ID) )
	#entry_ID.bind('<KeyRelease>', lambda args: enter_keyboardkKey(entry_ID) ) # for dynamic realtime feedback capture
	entry_ID.bind("<FocusIn>", lambda args: entry_ID_click( entry_ID))
	entry_ID.bind("<FocusOut>", lambda args: entry_ID_check(entry_ID,label_3,book_Btn))
	entry_ID.insert(0, '0')
	entry_ID.place( x=(width/2)+48 , y=705+x , anchor='center') # alternative to entry_ID.pack()
	#entry_ID.focus_set() # to automatically focus on the widget at start up


	# --- SELECTED FLIGHT ID widget ---
	label_3 = Label( se_window , width=85 , text='' , fg=css.color_text , bg=css.color_bg_newSession )
	label_3.place( x=width/2 , y=747+x , anchor='center' )
	label_3.config( font=( "Helvetica", 16 , "normal" ) )	# normal, bold, roman, italic, underline, and overstrike
	label_3.config( text='' )


	# --- SEARCH BUTTON widget ---
	searchButton = Button( se_window , width=15, text='SEARCH', fg=css.color_text, bg=css.color_btn )
	searchButton.config( highlightbackground=css.color_bg_newSession )
	searchButton.config( font=( "Helvetica", 20 , "bold" ) )
	searchButton.config( bd=8, relief='raised' )
	searchButton.config( command=print_search_results )
	searchButton.place( x=width/2 , y=445+x , anchor='center')


	# --- BOOK FLIGHT BUTTON widget ---
	book_Btn = Button( se_window , width=15, text='Book Flight', fg=css.color_text, bg=css.color_btn, relief='ridge' )
	book_Btn.config( highlightbackground=css.color_bg_newSession )
	book_Btn.config( font=( "Helvetica", 20 , "bold" ) )
	book_Btn.config( bd=8, relief='raised' )					# flat, groove, raised, ridge, solid, or sunken
	book_Btn.config( command=lambda: btn_click_bookFlight(label_3,book_Btn) )
	#book_Btn.config( command=book)
	#book_Btn.bind('<Button-1>', hide_me)
	#book_Btn.place( x=css.frame_center_W , y=785+x , anchor='center')
	btn_visibility_toggle( book_Btn , False)


	# --- LOG-IN BUTTON widget ---
	login_Btn = Button(se_window, width=10, text='admin', fg=css.color_text, bg=css.color_btn)
	login_Btn.config( highlightbackground=css.color_bg_newSession )
	login_Btn.config(font=("Helvetica", 15, "bold"))
	login_Btn.config(bd=8, relief='raised')  # flat, groove, raised, ridge, solid, or sunken
	login_Btn.config(command=btn_click_LogIn)  # calls btn_click_LogIn() when the button is clicked
	login_Btn.place(x=100, y=26, anchor='center')

	# --- LOGGED IN USER LABEL widget ---
	label_user = Label( se_window , width=15 , text='' , fg=css.color_text , bg=css.color_bg_newSession )
	label_user.place( x=width-100 , y=26 , anchor='center' )
	label_user.config( font=( "Helvetica", 16 , "bold" ) )	# normal, bold, roman, italic, underline, and overstrike
	label_user.config( text=str("user: "******"WM_DELETE_WINDOW", on_closing)