Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from tkinter import *
- from tkinter import ttk
- import sqlite3 as sql
- gui = Tk()
- gui.geometry("400x400+350+250")
- def register():
- conn= sql.connect("OS_Employee.db")
- with conn:
- cur = conn.cursor()
- try:
- EmployeeID = int(input("Enter New Employee ID: "))
- EMP_ID_entrybox = (row=1,column=1)
- EmployeeID = EMP_ID_entrybox
- FirstName = input("What's your first name:")
- EMP_FirstName_entrybox = (row=2,column=1)
- FirstName = FirstName.title()
- LastName = input("what's your last name: ")
- LastName_entrybox= (row=3,column=1)
- LastName = LastName.title()
- Email = input("Email: ")
- Email_entrybox = (row=4,column=l)
- Email = Email.lower()
- Password = input("Enter a password: ")
- Password_entrybox = (row=5,column=1)
- Password = Password.lower()
- cur.execute(
- 'insert into employee values(?,?,?,?,?)',
- (EmployeeID, FirstName, LastName, Email, Password))
- cur.execute(
- 'select * from employee where EmployeeId=?',
- (EmployeeID,))
- results = cur.fetchall()
- print(results)
- except sql.IntegrityError:
- print("Connection Failed")
- conn = sql.connect('OS_employee.db')
- with conn:
- cur = conn.cursor()
- print("successfully connected")
- existingUser = input("Existing user?[yes/no]")
- if existingUser == "no":
- register()
- else:
- login()
- def LoginPage():
- mGui = Tk()
- mGui.geometry("400x400+350+250")
- mGui.title("Login Page")
- mGui.configure(background="light grey")
- lplabel1 = Label(mGui,text="Enter ID and Password", bg="light grey").grid(row=0,column = 0)
- lplabel2 = Label(mGui ,text="ID:", bg="light grey").grid(sticky="E",row=1,column = 0)
- lplabel3 = Label(mGui ,text="Password:", bg="light grey").grid(sticky="E",row=3,column=0)
- lpentry1 = Entry(mGui).grid(row=1,column=1)
- lpentry2 = Entry(mGui).grid(row=3,column=1, pady=10)
- lpbutton1 = Button(mGui ,text="back", bg = "dark gray", fg = "white", width="7", command=HomePage).grid(sticky="W",row=5,column=1)
- lpbutton2 = Button(mGui ,text="continue",bg = "#70ad47", fg = "white", width="7", command=Deliverable).grid(sticky="E",row=5,column=1)
- mGui.mainloop()
- def HomePage():
- bGui = Tk()
- bGui.geometry("400x400+350+250")
- bGui.title("Home Page")
- bGui.configure(background="light grey")
- bhplabel1 = Label(bGui,text="Buisness Solution", bg="light grey").grid(sticky="W,E",row=0,column = 0)
- bhplabel2 = Label(bGui,text="online office supply retailer that ships furniture, tech, pens,\n files, etc. to consumers and corperations nation wide.", bg="light grey",bd=1,relief="solid").grid(row=1,column=0)
- bhplabel3 = Label(bGui,text=" ", bg="light grey", height="1").grid(sticky="E",row=3,column = 0)
- bhpbutton1 = Button(bGui ,text="Login", width="10", command=LoginPage,bg = "#70ad47").grid(row=4,column=0)
- bhplabel4 = Label(bGui,text=" ", bg="light grey", height="1").grid(sticky="E",row=5,column = 0)
- bhpbutton2 = Button(bGui ,text="New User?", width="10",bg = "#70ad47", command=RegistrationPage).grid(row=6,column=0)
- bGui.mainloop()
- def RegistrationPage():
- gui = Tk()
- gui.geometry("400x400+350+250")
- gui.title("registration page")
- gui.configure(background="light grey")
- rplabel1 = Label(gui,text="Complete the fields below", bg="light grey").grid(row=0,column = 0)
- rplabel2 = Label(gui ,text="Username:", bg="light grey").grid(sticky="E",row=1,column = 0)
- rplabel3 = Label(gui ,text="Employee ID:", bg="light grey").grid(sticky="E",row=2,column=0)
- rpentry1 = Entry(gui).grid(row=1,column=1)
- rpentry2 = Entry(gui).grid(row=2,column=1)
- rplabel4 = Label(gui ,text="E-mail:", bg="light grey").grid(sticky="E",row=3,column = 0)
- rplabel5 = Label(gui ,text="Password:", bg="light grey").grid(sticky="E",row=4,column=0)
- rpentry3 = Entry(gui).grid(row=3,column=1)
- rpentry4 = Entry(gui).grid(row=4,column=1)
- rplabel6 = Label(gui ,text="Confirm PW:", bg="light grey").grid(sticky="E",row=5,column = 0)
- rpentry4 = Entry(gui).grid(row=5,column=1)
- rpbutton1 = Button(gui ,text="back", command=HomePage, bg = "dark gray", width="7").grid(sticky="w",row=6,column=1)
- rpbutton2 = Button(gui ,text="continue",bg = "#70ad47", width="7", command=LoginPage).grid(sticky="E",row=6,column=1)
- gui.mainloop()
- def Deliverable():
- gui = Tk()
- gui.geometry("400x400+350+250")
- var1 = IntVar()
- with conn:
- cur = conn.cursor()
- try:
- loginTest = False # main condition to loop if email and password not met
- while not loginTest: # wrong email loopy
- userEmail = input("Email please: ")
- userEmail = userEmail.replace(" ", "")
- userPassword = input("Password: ")
- userPassword = userPassword.strip()
- cur.execute(
- "SELECT COUNT (*) FROM Employee WHERE(Email= '" + userEmail.lower() + "' AND Password= '" + userPassword + "')")
- results = cur.fetchone() # return very first thing it finds that matches
- print(results[0]) # print first thing
- if results[0] == 1:
- print("login successful")
- loginTest = True
- else:
- print("no login!")
- existingUser = input("Existing user?[yes/no]")
- if existingUser == "no":
- register()
- except:
- print("connection failed")
- gui.title("name this")
- gui.configure(background="light grey")
- a = Label(gui,text="Select what to display", bg="light grey").grid(sticky="w",row=0,column = 0)
- b = Label(gui,text="10 Most Profitable:", bg="light grey").grid(sticky="E",row=1,column = 0)
- c = Label(gui,text="10 least profitable:", bg="light grey").grid(sticky="E",row=2,column = 0)
- #v = tk.IntVar()
- Radiobutton(gui, variable=var1, value=1, bg="light grey").grid(sticky="W",row=2,column=1)
- Radiobutton(gui, variable=var1, value=2, bg="light grey").grid(sticky="W",row=1,column=1)
- #Checkbutton(gui, variable=var1, bg="light grey").grid(sticky="W",row=1,column = 1)
- #Checkbutton(gui, variable=var1, bg="light grey").grid(sticky="W",row=2,column = 1)
- d = Label(gui,text="Which State:", bg="light grey").grid(sticky="E",row=3,column = 0)
- e = Label(gui,text="Which Product:", bg="light grey").grid(sticky="E",row=4,column = 0)
- f = Label(gui,text="Year:", bg="light grey").grid(sticky="E",row=5,column = 0)
- g = Label(gui,text="Month:", bg="light grey").grid(sticky="E",row=6,column = 0)
- h = Label(gui,text="Quarter:", bg="light grey").grid(sticky="E",row=7,column = 0)
- i = Entry(gui).grid(row=6,column=1)
- j = Entry(gui).grid(row=7,column=1)
- k = Label(gui,text=" ", bg="light grey", height="1").grid(sticky="E",row=8,column = 0)
- k = Label(gui,text=" ", bg="light grey", height="1").grid(sticky="E",row=8,column = 0)
- l = Button(gui ,text="LogOut", bg="red", fg="white", command=HomePage).grid(sticky="w",row=9,column=1)
- m = Button(gui ,text="continue", bg="#70ad47", fg="white").grid(sticky="E",row=9,column=1)
- stateMainframe = Frame(gui) #Which State
- stateMainframe.grid(row=3,column=1, sticky="W" )
- stateMainframe.columnconfigure(0, weight = 1)
- stateMainframe.rowconfigure(0, weight = 1)
- svar = StringVar(gui)
- states = { "Alabama", "Alaska", "Arizona", "Arkansas", "California", "Colorado", "Connecticut"}
- svar.set("Chose your location")
- stateMenu = OptionMenu(stateMainframe, svar, *states).grid(row = 3, column =1)
- def state_dropdown(*args):
- print( svar.get() )
- svar.trace('w', state_dropdown) #Which State
- productMainframe = Frame(gui) #Which Product
- productMainframe.grid(row=4,column=1, sticky="W" )
- productMainframe.columnconfigure(0, weight = 1)
- productMainframe.rowconfigure(0, weight = 1)
- pvar = StringVar(gui)
- products = { "Chairs", "Pens", "Televisions", "Desks", "Staplers", "Couches", "Laptops"}
- pvar.set("Chose your product")
- productMenu = OptionMenu(productMainframe, pvar, *products).grid(row = 4, column =1)
- def product_dropdown(*args):
- print( pvar.get() )
- pvar.trace('w', product_dropdown) #Which Product
- yearMainframe = Frame(gui) #Which year
- yearMainframe.grid(row=5,column=1, sticky="W" )
- yearMainframe.columnconfigure(0, weight = 1)
- yearMainframe.rowconfigure(0, weight = 1)
- yvar = IntVar(gui)
- years = { "2012", "2013", "2014", "2015", "2016", "2017", "2018"}
- yvar.set("Chose the year") # set the default option
- yearMenu = OptionMenu(yearMainframe, yvar, *years).grid(row = 5, column =1)
- def year_dropdown(*args):
- print( yvar.get() )
- yvar.trace('w', year_dropdown) #Which year
- gui.mainloop()
- gui.title("Home Page")
- gui.configure(background="light grey")
- hplabel1 = Label(gui,text="Buisness Solution", bg="light grey").grid(sticky="W,E",row=0,column = 0)
- hplabel2 = Label(gui,text="online office supply retailer that ships furniture, tech, pens,\n files, etc. to consumers and corperations nation wide.", bg="light grey",bd=1,relief="solid").grid(row=1,column=0)
- hplabel4 = Label(gui,text=" ", bg="light grey", height="1").grid(sticky="E",row=3,column = 0)
- hpbutton1 = Button(gui ,text="Login", width="10", command=LoginPage,bg = "#70ad47", fg = "white").grid(row=4,column=0)
- hplabel5 = Label(gui,text=" ", bg="light grey", height="1").grid(sticky="E",row=5,column = 0)
- hpbutton2 = Button(gui ,text="New User?", width="10",bg = "#70ad47", fg = "white", command=RegistrationPage).grid(row=6,column=0)
- gui.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement