Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 43 additions & 27 deletions GraphicUser_InterFace/Display_availability.py
Original file line number Diff line number Diff line change
@@ -1,48 +1,64 @@
import customtkinter
import customtkinter as ctk
import Modules.SQL as sql
import Modules.FileHandling as File

class Available(customtkinter.CTk):
class Available(ctk.CTk):
def __init__(self):
super().__init__()

self.setup_window()
self.create_widgets()
self.populate_textbox()

def setup_window(self):
self.geometry("700x300")
self.title("Route Information Page")
self.minsize(300, 200)

self.grid_rowconfigure(0, weight=1)
self.grid_columnconfigure((0, 1), weight=1)

self.textbox = customtkinter.CTkTextbox(master=self)
def create_widgets(self):
self.textbox = ctk.CTkTextbox(master=self, font=("Arial", 18))
self.textbox.grid(row=0, column=0, columnspan=2, padx=20, pady=(20, 0), sticky="nsew")
self.textbox.configure(font=("Arial", 18))

self.combobox = ctk.CTkComboBox(master=self, values=self.get_combobox_values())
self.combobox.grid(row=1, column=0, padx=20, pady=20, sticky="ew")

self.button = ctk.CTkButton(master=self, command=self.button_callback, text="Proceed")
self.button.grid(row=1, column=1, padx=20, pady=20, sticky="ew")

AvailableList = sql.Query_FetchFromFile()
AvailableList.reverse()
list=[]
indexing_Choices=len(AvailableList)
for i in range(AvailableList.__len__()):
self.textbox.insert("0.0",str(indexing_Choices)+"). "+AvailableList[i]+"\n")
indexing_Choices=indexing_Choices-1
list.append("Choice "+ str(indexing_Choices+1))
list.append("Select")
list.reverse()
def populate_textbox(self):
try:
available_list = sql.Query_FetchFromFile()
available_list.reverse()
indexing_choices = len(available_list)

self.combobox = customtkinter.CTkComboBox(master=self, values=list)
self.combobox.grid(row=1, column=0, padx=20, pady=20, sticky="ew")
self.button = customtkinter.CTkButton(master=self, command=self.button_callback, text="Proceed")
self.button.grid(row=1, column=1, padx=20, pady=20, sticky="ew")

for item in available_list:
self.textbox.insert("0.0", f"{indexing_choices}). {item}\n")
indexing_choices -= 1
except Exception as e:
self.textbox.insert("0.0", f"Error fetching data: {e}\n")

def get_combobox_values(self):
try:
available_list = sql.Query_FetchFromFile()
values = [f"Choice {i+1}" for i in range(len(available_list))]
values.append("Select")
return values[::-1]
except Exception as e:
return [f"Error fetching data: {e}"]

def button_callback(self):
selection = self.combobox.get()
File.Handle_Selection(selection)
self.destroy()
import Payment
Payment.mainloop()

try:
File.Handle_Selection(selection)
except Exception as e:
print(f"Error handling selection: {e}")
finally:
self.destroy()
import Payment
Payment.mainloop()

if __name__ == "__main__":
Available = App()
Available.mainloop()
app = Available()
app.mainloop()