from tkinter import *
from tkinter import ttk
import datetime
import pickle
name = ""
course = ""
reference_number = ""
email = ""
timestamp = ""
room_number = ""
facebook = ""
data = {}
now = datetime.datetime.now()
filewin = Tk()
style = ttk.Style()
style.configure("TLabel", foreground="black", font = 'Courier 10')
ttk.Style().configure("TButton", padding=3, relief="flat", background="#ccc",font = 'Courier 10')
filewin.title("Queen's Hall Data Manager",)
filewin.geometry("900x500+500+250")
label = ttk.Label(filewin, text = "Please Enter Your Info in the boxes below",foreground='blue')
label.place(x= 100, y=25)
notebook = ttk.Notebook(filewin)
notebook.place(x = 100, y = 50, width = 450)
frame1 = ttk.Frame(notebook)
frame2 = ttk.Frame(notebook)
frame3 = ttk.Frame(notebook)
notebook.add(frame1, text = 'ADD USER')
notebook.add(frame2, text = 'DISPLAY')
notebook.add(frame3, text = 'SEARCH')
##########################################################################FRAME 1
label = ttk.Label(frame1, text="Full Name :", foreground='blue',)
label.grid(row=1, column=1,sticky = 'W', padx = 15, pady = 10)
entry_box1= ttk.Entry(frame1, width = 35,)
entry_box1.place(x= 100, y = 10)
label = ttk.Label(frame1, text="Course :",foreground='blue')
label.grid(row=2, column=1,sticky = 'W', padx = 15, pady = 10)
entry_box2= ttk.Entry(frame1, width = 35,)
entry_box2.place(x= 100, y = 48)
label = ttk.Label(frame1, text="Ref Num :",foreground='blue')
label.grid(row=3, column=1,sticky = 'W', padx = 15, pady = 10)
entry_box3= ttk.Entry(frame1, width = 35,)
entry_box3.place(x= 100, y = 87)
label = ttk.Label(frame1, text="Room :",foreground='blue')
label.grid(row=4, column=1,sticky = 'W', padx = 15, pady = 10)
entry_box4= ttk.Entry(frame1, width = 35,)
entry_box4.place(x= 100, y = 126)
ticked_main = BooleanVar()
ticked_annex = BooleanVar()
main = ttk.Checkbutton(frame1, text = "Main", variable = ticked_main)
annex = ttk.Checkbutton(frame1, text = "Annex", variable = ticked_annex)
label = ttk.Label(frame1, text="Facebook :",foreground='blue')
label.grid(row=5, column=1,sticky = 'W', padx = 15, pady = 10)
entry_box5= ttk.Entry(frame1, width = 35,)
entry_box5.place(x= 100, y = 167)
label = ttk.Label(frame1, text="Email :",foreground='blue')
label.grid(row=6, column=1,sticky = 'W', padx = 15, pady = 10)
entry_box6= ttk.Entry(frame1, width = 35,)
entry_box6.place(x= 100, y = 207)
label = ttk.Label(frame1, text="D.O.B :",foreground='blue')
label.grid(row=7, column=1,sticky = 'W', padx = 15, pady = 10)
entry_box7= ttk.Entry(frame1, width = 35,)
entry_box7.place(x= 100, y = 247)
label = ttk.Label(frame1, text="Phone :",foreground='blue')
label.grid(row=8, column=1,sticky = 'W', padx = 15, pady = 10)
entry_box8= ttk.Entry(frame1, width = 35,)
entry_box8.place(x= 100, y = 287)
def adduser():
name = "Name: " + entry_box1.get()
course = "Course: " + entry_box2.get()
reference_number = "Ref Number : " + entry_box3.get()
room_number = 'room_number : ' + entry_box4.get()
main = 'Main :' + str(ticked_main.get())
annex = 'Annex : '+ str(ticked_annex.get())
facebook = 'Facebook = :' + entry_box5.get()
email = "Email : " + entry_box6.get()
timestamp = str(now)
data[name] = course, reference_number, room_number, main, annex, facebook,email, timestamp
addstudent = open ("data.txt", "a")
addstudent.write(str(data))
addstudent.close()
def clear_entry():
entry_box1.delete(0, END)
entry_box2.delete(0, END)
entry_box3.delete(0, END)
entry_box4.delete(0, END)
entry_box5.delete(0, END)
entry_box6.delete(0, END)
entry_box7.delete(0, END)
entry_box8.delete(0, END)
def exitmode():
m = Message(filewin, text = "Are you Tired of Typing???", foreground='blue')
filewin.destroy()
b = ttk.Button(frame1, text="Add New Royal", command=adduser)
b.grid(row=9, column=1,sticky = 'W', padx = 15, pady = 10)
r = ttk.Button(frame1, text="Show Logo", state='disabled')
r.grid(row=9, column=2,sticky = 'W', padx = 10, pady = 10)
e = ttk.Button(frame1, text="Exit", command=exitmode)
e.grid(row=9, column=2,sticky = 'W', padx = 10, pady = 10)
c = ttk.Button(frame1, text="CLEAR", command=clear_entry)
c.grid(row=9, column=3,sticky = 'W', padx = 10, pady = 10)
#######################################FRAME 2
s_b = ttk.Entry(frame2, width = 25,)
s_b.place(x= 130, y = 20)
tt = Text(frame2,width = 50,height = 13)
tt.grid(row=2, column=1, padx = 15, pady = 1)
def read():
query = open ("data.txt", "r").read()
data = eval(query)
name = "Name: " + s_b.get()
if name in data:
tt.insert(0.,data[name])
#print(data[name])
s_earch = ttk.Label(frame2, text="SEARCH BY NAME :",foreground='blue')
s_earch.grid(row=1, column=1,sticky = 'W', padx = 15, pady = 20)
frame2b = ttk.Button(frame2, text="SEARCH", command=read)
frame2b.place(x = 300, y= 10)
#
ss3 = ttk.Label(frame3, text="ROOM :",foreground='blue')
ss3.grid(row=1, column=1,sticky = 'W', padx = 15, pady = 20)
sb3= ttk.Entry(frame3, width = 25,)
sb3.place(x= 130, y = 20)
fram3b = ttk.Button(frame3, text="DISPLAY")
fram3b.place(x = 300, y= 10)
ff3 = Text(frame3,width = 50,height = 18)
ff3.grid(row=2, column=1, padx = 15, pady = 1)
filewin.mainloop()