import tkinter as tk import backend from tkinter import ttk, messagebox import backend class student: def __init__(self,window): self.window = window self.frame = tk.Frame(self.window,bg='grey71',width=700,height=400) self.label = tk.Label(self.frame,text='Student User',bg='grey6',fg= 'white',font=('Arial',20,'bold')) self.label.place(x=20,y=10,width=200,height=30) self.label_title = tk.Label(self.frame, text='TITLE',bg='grey71',font=('Georgia',14,'bold')) self.label_title.place(x=20,y=100,width=100,height=50) self.label_year = tk.Label(self.frame, text='YEAR',bg='grey71',font=('Georgia',14,'bold')) self.label_year.place(x=20,y=150,width=100,height=30) self.label_author = tk.Label(self.frame, text='AUTHOR',bg='grey71',font=('Georgia',14,'bold')) self.label_author.place(x=350,y=100,width=100,height=30) self.label_isbn = tk.Label(self.frame, text='ISBN',bg='grey71',font=('Georgia',14,'bold')) self.label_isbn.place(x=350,y=150,width=100,height=30) self.title_text=tk.StringVar() self.entry_title = tk.Entry(self.frame, fg='gray',textvariable=self.title_text,width=25,font=('Arial',12,'bold')) self.entry_title.place(x=120,y=100,width=150,height=30) self.year_text=tk.StringVar() self.entry_year = tk.Entry(self.frame, fg='gray',textvariable=self.year_text,width=25,font=('Arial',12,'bold')) self.entry_year.place(x=120,y=150,width=150,height=30) self.author_text=tk.StringVar() self.entry_author = tk.Entry(self.frame, fg='gray',textvariable=self.author_text,width=25,font=('Arial',12,'bold')) self.entry_author.place(x=470,y=100,width=150,height=30) self.isbn_text=tk.StringVar() self.entry_isbn = tk.Entry(self.frame, fg='gray',textvariable=self.isbn_text,width=25,font=('Arial',12,'bold')) self.entry_isbn.place(x=470,y=150,width=150,height=30) self.listbox = tk.Listbox(self.frame) self.listbox.place(x=100,y=200,width=500,height=100) self.button_view = tk.Button(self.frame,text='View All',bg='forest green',fg='gray12',font=('Arial',10,'bold'), command=self.view_command) self.button_view.place(x=100,y=320,width=100,height=40) self.button_search = tk.Button(self.frame,text='Search ',bg='forest green',fg='gray12',font=('Arial',10,'bold'), command=self.search_command) self.button_search.place(x=200,y=320,width=100,height=40) self.button_issue = tk.Button(self.frame,text='Issue', bg='forest green',fg='gray12',font=('Arial',10,'bold'),command=self.issue_command) self.button_issue.place(x=300,y=320,width=100,height=40) self.button_request = tk.Button(self.frame, text='Request',bg='forest green',fg='gray12',font=('Arial',10,'bold'), command = self.request_command) self.button_request.place(x=400, y=320,width=100,height=40) self.button_issue = tk.Button(self.frame, text='Clear Fields',bg='forest green',fg='gray12',font=('Arial',10,'bold'), command=self.clear_command) self.button_issue.place(x=500, y=320,width=100,height=40) self.frame.pack() def clear_command(self): self.entry_title.delete(0,tk.END) self.entry_year.delete(0,tk.END) self.entry_author.delete(0,tk.END) self.entry_isbn.delete(0,tk.END) def request_command(self): backend.request_insert(self.title_text.get(),self.author_text.get(),self.year_text.get(),self.isbn_text.get()) self.listbox.delete(0,tk.END) self.listbox.insert(tk.END,(self.title_text.get(),self.author_text.get(),self.year_text.get(),self.isbn_text.get())) def issue_command(self): selected_tuple=self.listbox.curselection() value = self.listbox.get(selected_tuple) self.entry_title.delete(0,tk.END) self.entry_title.insert(tk.END,value[1]) self.entry_year.delete(0,tk.END) self.entry_year.insert(tk.END,value[2]) self.entry_author.delete(0,tk.END) self.entry_author.insert(tk.END,value[3]) self.entry_isbn.delete(0,tk.END) self.entry_isbn.insert( tk.END,value[4]) backend.issue_insert(value[0]) def view_command(self): self.listbox.delete(0,tk.END) for row in backend.view(): self.listbox.insert(tk.END,row) def search_command(self): self.listbox.delete(0,tk.END) for row in backend.search(self.title_text.get(),self.author_text.get(),self.year_text.get(),self.isbn_text.get()): self.listbox.insert(tk.END,row) backend.connect() backend.issue() backend.request() window = tk.Tk() window.title('Student User Page') window.geometry('700x400') obj = student(window) window.mainloop()