Advertisement
Guest User

progress/ yeeeeeesssss

a guest
Nov 28th, 2018
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.86 KB | None | 0 0
  1. from tkinter import *
  2. from tkinter import ttk
  3. import sqlite3 as sql
  4. gui = Tk()
  5. gui.geometry("400x400+350+250")
  6.  
  7. def register():
  8. conn= sql.connect("OS_Employee.db")
  9. with conn:
  10. cur = conn.cursor()
  11. try:
  12. EmployeeID = int(input("Enter New Employee ID: "))
  13. EMP_ID_entrybox = (row=1,column=1)
  14. EmployeeID = EMP_ID_entrybox
  15.  
  16. FirstName = input("What's your first name:")
  17. EMP_FirstName_entrybox = (row=2,column=1)
  18. FirstName = FirstName.title()
  19.  
  20. LastName = input("what's your last name: ")
  21. LastName_entrybox= (row=3,column=1)
  22. LastName = LastName.title()
  23.  
  24. Email = input("Email: ")
  25. Email_entrybox = (row=4,column=l)
  26. Email = Email.lower()
  27.  
  28. Password = input("Enter a password: ")
  29. Password_entrybox = (row=5,column=1)
  30. Password = Password.lower()
  31. cur.execute(
  32. 'insert into employee values(?,?,?,?,?)',
  33. (EmployeeID, FirstName, LastName, Email, Password))
  34. cur.execute(
  35. 'select * from employee where EmployeeId=?',
  36. (EmployeeID,))
  37.  
  38. results = cur.fetchall()
  39. print(results)
  40. except sql.IntegrityError:
  41. print("Connection Failed")
  42.  
  43.  
  44.  
  45. conn = sql.connect('OS_employee.db')
  46. with conn:
  47. cur = conn.cursor()
  48. print("successfully connected")
  49. existingUser = input("Existing user?[yes/no]")
  50. if existingUser == "no":
  51. register()
  52. else:
  53. login()
  54. def LoginPage():
  55. mGui = Tk()
  56. mGui.geometry("400x400+350+250")
  57. mGui.title("Login Page")
  58. mGui.configure(background="light grey")
  59. lplabel1 = Label(mGui,text="Enter ID and Password", bg="light grey").grid(row=0,column = 0)
  60. lplabel2 = Label(mGui ,text="ID:", bg="light grey").grid(sticky="E",row=1,column = 0)
  61. lplabel3 = Label(mGui ,text="Password:", bg="light grey").grid(sticky="E",row=3,column=0)
  62. lpentry1 = Entry(mGui).grid(row=1,column=1)
  63. lpentry2 = Entry(mGui).grid(row=3,column=1, pady=10)
  64. lpbutton1 = Button(mGui ,text="back", bg = "dark gray", fg = "white", width="7", command=HomePage).grid(sticky="W",row=5,column=1)
  65. lpbutton2 = Button(mGui ,text="continue",bg = "#70ad47", fg = "white", width="7", command=Deliverable).grid(sticky="E",row=5,column=1)
  66. mGui.mainloop()
  67.  
  68. def HomePage():
  69. bGui = Tk()
  70. bGui.geometry("400x400+350+250")
  71. bGui.title("Home Page")
  72. bGui.configure(background="light grey")
  73. bhplabel1 = Label(bGui,text="Buisness Solution", bg="light grey").grid(sticky="W,E",row=0,column = 0)
  74. 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)
  75. bhplabel3 = Label(bGui,text=" ", bg="light grey", height="1").grid(sticky="E",row=3,column = 0)
  76. bhpbutton1 = Button(bGui ,text="Login", width="10", command=LoginPage,bg = "#70ad47").grid(row=4,column=0)
  77. bhplabel4 = Label(bGui,text=" ", bg="light grey", height="1").grid(sticky="E",row=5,column = 0)
  78. bhpbutton2 = Button(bGui ,text="New User?", width="10",bg = "#70ad47", command=RegistrationPage).grid(row=6,column=0)
  79. bGui.mainloop()
  80.  
  81. def RegistrationPage():
  82. gui = Tk()
  83. gui.geometry("400x400+350+250")
  84. gui.title("registration page")
  85. gui.configure(background="light grey")
  86. rplabel1 = Label(gui,text="Complete the fields below", bg="light grey").grid(row=0,column = 0)
  87. rplabel2 = Label(gui ,text="Username:", bg="light grey").grid(sticky="E",row=1,column = 0)
  88. rplabel3 = Label(gui ,text="Employee ID:", bg="light grey").grid(sticky="E",row=2,column=0)
  89. rpentry1 = Entry(gui).grid(row=1,column=1)
  90. rpentry2 = Entry(gui).grid(row=2,column=1)
  91. rplabel4 = Label(gui ,text="E-mail:", bg="light grey").grid(sticky="E",row=3,column = 0)
  92. rplabel5 = Label(gui ,text="Password:", bg="light grey").grid(sticky="E",row=4,column=0)
  93. rpentry3 = Entry(gui).grid(row=3,column=1)
  94. rpentry4 = Entry(gui).grid(row=4,column=1)
  95. rplabel6 = Label(gui ,text="Confirm PW:", bg="light grey").grid(sticky="E",row=5,column = 0)
  96. rpentry4 = Entry(gui).grid(row=5,column=1)
  97. rpbutton1 = Button(gui ,text="back", command=HomePage, bg = "dark gray", width="7").grid(sticky="w",row=6,column=1)
  98. rpbutton2 = Button(gui ,text="continue",bg = "#70ad47", width="7", command=LoginPage).grid(sticky="E",row=6,column=1)
  99. gui.mainloop()
  100.  
  101.  
  102. def Deliverable():
  103. gui = Tk()
  104. gui.geometry("400x400+350+250")
  105. var1 = IntVar()
  106. with conn:
  107. cur = conn.cursor()
  108. try:
  109. loginTest = False # main condition to loop if email and password not met
  110. while not loginTest: # wrong email loopy
  111. userEmail = input("Email please: ")
  112. userEmail = userEmail.replace(" ", "")
  113. userPassword = input("Password: ")
  114. userPassword = userPassword.strip()
  115. cur.execute(
  116. "SELECT COUNT (*) FROM Employee WHERE(Email= '" + userEmail.lower() + "' AND Password= '" + userPassword + "')")
  117. results = cur.fetchone() # return very first thing it finds that matches
  118. print(results[0]) # print first thing
  119. if results[0] == 1:
  120. print("login successful")
  121. loginTest = True
  122. else:
  123. print("no login!")
  124. existingUser = input("Existing user?[yes/no]")
  125. if existingUser == "no":
  126. register()
  127. except:
  128. print("connection failed")
  129.  
  130. gui.title("name this")
  131. gui.configure(background="light grey")
  132. a = Label(gui,text="Select what to display", bg="light grey").grid(sticky="w",row=0,column = 0)
  133. b = Label(gui,text="10 Most Profitable:", bg="light grey").grid(sticky="E",row=1,column = 0)
  134. c = Label(gui,text="10 least profitable:", bg="light grey").grid(sticky="E",row=2,column = 0)
  135. #v = tk.IntVar()
  136. Radiobutton(gui, variable=var1, value=1, bg="light grey").grid(sticky="W",row=2,column=1)
  137. Radiobutton(gui, variable=var1, value=2, bg="light grey").grid(sticky="W",row=1,column=1)
  138. #Checkbutton(gui, variable=var1, bg="light grey").grid(sticky="W",row=1,column = 1)
  139. #Checkbutton(gui, variable=var1, bg="light grey").grid(sticky="W",row=2,column = 1)
  140. d = Label(gui,text="Which State:", bg="light grey").grid(sticky="E",row=3,column = 0)
  141. e = Label(gui,text="Which Product:", bg="light grey").grid(sticky="E",row=4,column = 0)
  142. f = Label(gui,text="Year:", bg="light grey").grid(sticky="E",row=5,column = 0)
  143. g = Label(gui,text="Month:", bg="light grey").grid(sticky="E",row=6,column = 0)
  144. h = Label(gui,text="Quarter:", bg="light grey").grid(sticky="E",row=7,column = 0)
  145. i = Entry(gui).grid(row=6,column=1)
  146. j = Entry(gui).grid(row=7,column=1)
  147. k = Label(gui,text=" ", bg="light grey", height="1").grid(sticky="E",row=8,column = 0)
  148. k = Label(gui,text=" ", bg="light grey", height="1").grid(sticky="E",row=8,column = 0)
  149. l = Button(gui ,text="LogOut", bg="red", fg="white", command=HomePage).grid(sticky="w",row=9,column=1)
  150. m = Button(gui ,text="continue", bg="#70ad47", fg="white").grid(sticky="E",row=9,column=1)
  151.  
  152. stateMainframe = Frame(gui) #Which State
  153. stateMainframe.grid(row=3,column=1, sticky="W" )
  154. stateMainframe.columnconfigure(0, weight = 1)
  155. stateMainframe.rowconfigure(0, weight = 1)
  156. svar = StringVar(gui)
  157.  
  158. states = { "Alabama", "Alaska", "Arizona", "Arkansas", "California", "Colorado", "Connecticut"}
  159. svar.set("Chose your location")
  160.  
  161. stateMenu = OptionMenu(stateMainframe, svar, *states).grid(row = 3, column =1)
  162.  
  163. def state_dropdown(*args):
  164. print( svar.get() )
  165.  
  166. svar.trace('w', state_dropdown) #Which State
  167.  
  168. productMainframe = Frame(gui) #Which Product
  169. productMainframe.grid(row=4,column=1, sticky="W" )
  170. productMainframe.columnconfigure(0, weight = 1)
  171. productMainframe.rowconfigure(0, weight = 1)
  172. pvar = StringVar(gui)
  173.  
  174. products = { "Chairs", "Pens", "Televisions", "Desks", "Staplers", "Couches", "Laptops"}
  175. pvar.set("Chose your product")
  176.  
  177. productMenu = OptionMenu(productMainframe, pvar, *products).grid(row = 4, column =1)
  178.  
  179. def product_dropdown(*args):
  180. print( pvar.get() )
  181.  
  182. pvar.trace('w', product_dropdown) #Which Product
  183.  
  184. yearMainframe = Frame(gui) #Which year
  185. yearMainframe.grid(row=5,column=1, sticky="W" )
  186. yearMainframe.columnconfigure(0, weight = 1)
  187. yearMainframe.rowconfigure(0, weight = 1)
  188. yvar = IntVar(gui)
  189.  
  190. years = { "2012", "2013", "2014", "2015", "2016", "2017", "2018"}
  191. yvar.set("Chose the year") # set the default option
  192.  
  193. yearMenu = OptionMenu(yearMainframe, yvar, *years).grid(row = 5, column =1)
  194.  
  195. def year_dropdown(*args):
  196. print( yvar.get() )
  197.  
  198. yvar.trace('w', year_dropdown) #Which year
  199.  
  200. gui.mainloop()
  201.  
  202.  
  203. gui.title("Home Page")
  204. gui.configure(background="light grey")
  205. hplabel1 = Label(gui,text="Buisness Solution", bg="light grey").grid(sticky="W,E",row=0,column = 0)
  206. 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)
  207. hplabel4 = Label(gui,text=" ", bg="light grey", height="1").grid(sticky="E",row=3,column = 0)
  208. hpbutton1 = Button(gui ,text="Login", width="10", command=LoginPage,bg = "#70ad47", fg = "white").grid(row=4,column=0)
  209. hplabel5 = Label(gui,text=" ", bg="light grey", height="1").grid(sticky="E",row=5,column = 0)
  210. hpbutton2 = Button(gui ,text="New User?", width="10",bg = "#70ad47", fg = "white", command=RegistrationPage).grid(row=6,column=0)
  211.  
  212.  
  213.  
  214.  
  215.  
  216. gui.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement