from tkinter import *
from tkinter import ttk
from tkinter import messagebox
from tkinter import filedialog 
from PIL import ImageTk, Image
import os

import dbProjects as projects

###########
#VARIBALES#
###########
colorBackgroundRoot="#06283D"

########
#WINDOW#
########
root = Tk()
root.title("Database Interface")
root.attributes('-type', 'dialog')#https://stackoverflow.com/questions/35830851/how-to-make-tkinter-window-floating-in-i3-windowmanager
root.geometry("1000x1000")
root.config(bg=colorBackgroundRoot)

#############
#DEFINITIONS#
#############
def errorMessage(error):
    response = messagebox.showerror("ERROR", error)


def dbSubmit(): 
    #Connect to database
    # Clear the text Boxes
    firstName.delete(0,END)
    lastName.delete(0,END)
    address.delete(0,END)
    city.delete(0,END)
    state.delete(0,END)
    zipCode.delete(0,END)

def dbQuery(): 
    return 0

################
#IMAGES & ICONS#
################


###########
#FUNCTIONS#
###########


########
#FRAMES#
########


#########
#WIDGETS#
#########
firstName = Entry(root,width=30)
lastName = Entry(root,width=30)
address = Entry(root,width=30)
city = Entry(root,width=30)
state = Entry(root,width=30)
zipCode = Entry(root,width=30)

firstNameLabel = Label(root,text="First Name: ")
lastNameLabel = Label(root,text="Last Name: ")
addressLabel = Label(root,text="Address: ")
cityLabel = Label(root,text="city: ")
stateLabel = Label(root,text="state: ")
zipCodeLabel = Label(root,text="Zip Code: ")

buttonSubmit = Button(root, text="add to db", command=dbSubmit) 
buttonQuery = Button(root, text="request from db", command=dbQuery) 

###########
#PLACEMENT#
###########
firstName.grid(row=0, column=1, padx=20)
firstNameLabel.grid(row=0, column=0)

lastName.grid(row=1, column=1, padx=20)
lastNameLabel.grid(row=1, column=0)

address.grid(row=2, column=1, padx=20)
addressLabel.grid(row=2, column=0)

city.grid(row=3, column=1, padx=20)
cityLabel.grid(row=3, column=0)

state.grid(row=4, column=1, padx=20)
stateLabel.grid(row=4, column=0)

zipCode.grid(row=5, column=1, padx=20)
zipCodeLabel.grid(row=5, column=0)

buttonSubmit.grid(row=6, column=0, columnspan=2, padx=10, pady=10, ipadx=100)
buttonQuery.grid(row=7, column=0, columnspan=2, padx=10, pady=10, ipadx=100)

projects.connect()

############
#DISPLAYING#
############
#Showing on the screen and aranging them
#Main Loop Equivalent of our main(); 
root.mainloop()