Advertisement
Guest User

progress

a guest
Dec 8th, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.27 KB | None | 0 0
  1. import tkinter as tk #importd tkinter and renames it as tk
  2.  
  3.  
  4. LARGE_FONT= ("Verdana", 12)
  5.  
  6.  
  7. class Gui(tk.Tk): #creat Gui class and inherit attributes of tk.TK
  8.  
  9. def __init__(self, *args, **kwargs): # the init methodology is going to initialize with the class right away this allows us to pass arguments and keyword arguments
  10.  
  11. tk.Tk.__init__(self, *args, **kwargs) #initialize tk within the initialization function
  12. container = tk.Frame(self) # defines the container to be filled with a bunch of frames to be used later
  13. container.pack(side="top", fill="both", expand = True) # configure general display
  14. container.grid_rowconfigure(0, weight=1)
  15. container.grid_columnconfigure(0, weight=1)
  16.  
  17. self.frames = {} #pre defined dictionary
  18. for F in (HomePage, LoginPage, RegistrationPage, Deliverable1, Display):
  19. frame = F(container, self)
  20. self.frames[F] = frame
  21. frame.grid(row=0, column=0, sticky="nsew") #using grid to place the widget
  22. self.show_frame(HomePage) #call show_frame to bring the frame we want
  23.  
  24. def show_frame(self, cont):
  25.  
  26. frame = self.frames[cont]
  27. frame.tkraise() # this will bring our frame to the top for the user to see
  28.  
  29.  
  30. class HomePage(tk.Frame):
  31.  
  32. def __init__(self, parent,controller): #homepage
  33. tk.Frame.__init__(self,parent)
  34. self.configure(background="light grey")
  35. label = tk.Label(self, text="Buisness Solution", font=LARGE_FONT, bg="light grey").pack()
  36. label1 = tk.Label(self, text="online office supply retailer that ships furniture, tech, pens,\n files, etc. to consumers and corperations nation wide.", font=LARGE_FONT, bg="light grey",bd=1,relief="solid")
  37. label1.pack(pady=10,padx=10)
  38. button = tk.Button(self, text="Login", bg="#70ad47", fg="white",
  39. command=lambda: controller.show_frame(LoginPage))
  40. button.pack()
  41.  
  42. button2 = tk.Button(self, text="New User?", bg="#70ad47", fg="white",
  43. command=lambda: controller.show_frame(RegistrationPage))
  44. button2.pack(pady=10)
  45.  
  46.  
  47. class LoginPage(tk.Frame):
  48.  
  49. def __init__(self, parent, controller,**kwargs): #LoginPage
  50. tk.Frame.__init__(self, parent,**kwargs)
  51. self.configure(background="light grey")
  52. label = tk.Label(self, text="Enter ID and Password", font=LARGE_FONT, bg="light grey").grid(row=0,column=0)
  53. label1 = tk.Label(self, text="ID:", font=LARGE_FONT, bg="light grey").grid(sticky="E",row=1,column=0)
  54. label2 = tk.Label(self, text="Password:", font=LARGE_FONT, bg="light grey").grid(sticky="E",row=2,column=0)
  55. entry1 = tk.Entry(self).grid(row=1,column=1)
  56. entry2 = tk.Entry(self).grid(row=2,column=1)
  57. button1 = tk.Button(self, text="Back", bg="dark gray", fg="white",
  58. command=lambda: controller.show_frame(HomePage))
  59. button1.grid(sticky="W",row=3,column=1,pady=4)
  60.  
  61. button2 = tk.Button(self, text="Continue", bg="#70ad47", fg="white", #continue should go to diliverables
  62. command=lambda: controller.show_frame(Deliverable1))
  63. button2.grid(sticky="E",row=3,column=1)
  64.  
  65.  
  66. class RegistrationPage(tk.Frame): #registrationpage
  67.  
  68. def __init__(self, parent, controller):
  69. tk.Frame.__init__(self, parent)
  70. self.configure(background="light grey")
  71. label = tk.Label(self, text="Complete the fields below", font=LARGE_FONT, bg="light grey").grid(row=0,column=0)
  72. label1 = tk.Label(self, text="Username:", font=LARGE_FONT, bg="light grey").grid(sticky="E",row=1,column=0)
  73. label2 = tk.Label(self, text="Employee ID:", font=LARGE_FONT, bg="light grey").grid(sticky="E",row=2,column=0)
  74. label3 = tk.Label(self, text="E-mail:", font=LARGE_FONT, bg="light grey").grid(sticky="E",row=3,column=0)
  75. label5 = tk.Label(self, text="Password:", font=LARGE_FONT, bg="light grey").grid(sticky="E",row=4,column=0)
  76. label6 = tk.Label(self, text="Confirm PW:", font=LARGE_FONT, bg="light grey").grid(sticky="E",row=5,column=0)
  77. entry1 = tk.Entry(self).grid(row=1,column=1)
  78. entry2 = tk.Entry(self).grid(row=2,column=1)
  79. entry3 = tk.Entry(self).grid(row=3,column=1)
  80. entry4 = tk.Entry(self).grid(row=4,column=1)
  81. entry5 = tk.Entry(self).grid(row=5,column=1)
  82.  
  83. button1 = tk.Button(self, text="Back", bg="dark gray", fg="white",
  84. command=lambda: controller.show_frame(HomePage))
  85. button1.grid(sticky="w",row=6,column=1,pady=4)
  86.  
  87. button2 = tk.Button(self, text="Continue", bg="#70ad47", fg="white",
  88. command=lambda: controller.show_frame(LoginPage))
  89. button2.grid(sticky="E",row=6,column=1)
  90.  
  91.  
  92.  
  93.  
  94. class Deliverable1(tk.Frame): #registrationpage
  95.  
  96. def __init__(self, parent, controller):
  97. tk.Frame.__init__(self, parent)
  98. self.configure(background="light grey")
  99. label = tk.Label(self, text="Select what to display", font=LARGE_FONT, bg="light grey").grid(row=0,column=0)
  100. label1 = tk.Label(self, text="10 Most Profitable:", font=LARGE_FONT, bg="light grey").grid(sticky="E",row=1,column=0)
  101. label2 = tk.Label(self, text="10 least profitable:", font=LARGE_FONT, bg="light grey").grid(sticky="E",row=2,column=0)
  102. label3 = tk.Label(self, text="Which State:", font=LARGE_FONT, bg="light grey").grid(sticky="E",row=3,column=0)
  103. label5 = tk.Label(self, text="Which Product:", font=LARGE_FONT, bg="light grey").grid(sticky="E",row=4,column=0)
  104. label6 = tk.Label(self, text="Year:", font=LARGE_FONT, bg="light grey").grid(sticky="E",row=5,column=0)
  105. label7 = tk.Label(self, text="Month:", font=LARGE_FONT, bg="light grey").grid(sticky="E",row=6,column=0)
  106. label8 = tk.Label(self, text="Quarter:", font=LARGE_FONT, bg="light grey").grid(sticky="E",row=7,column=0)
  107. entry1 = tk.Entry(self).grid(sticky="W",row=6,column=1)
  108. entry2 = tk.Entry(self).grid(sticky="W",row=7,column=1)
  109.  
  110. v = tk.IntVar()
  111. tk.Radiobutton(self, variable=v, value=1, bg="light grey").grid(sticky="W",row=2,column=1)
  112. tk.Radiobutton(self, variable=v, value=2, bg="light grey").grid(sticky="W",row=1,column=1)
  113.  
  114. button1 = tk.Button(self, text="Log Out", bg="red", fg="white", #make the back button a logout button?
  115. command=lambda: controller.show_frame(HomePage))
  116. button1.grid(sticky="w",row=8,column=1,pady=5)
  117.  
  118. button2 = tk.Button(self, text="Continue", bg="#70ad47", fg="white", #go to displayproducts in order
  119. command=lambda: controller.show_frame(Display))
  120. button2.grid(sticky="E",row=8,column=1)
  121.  
  122. stateMainframe = tk.Frame(self) #Which State
  123. stateMainframe.grid(row=3,column=1, sticky="W" )
  124. stateMainframe.columnconfigure(0, weight = 1)
  125. stateMainframe.rowconfigure(0, weight = 1)
  126. svar = tk.StringVar(self)
  127.  
  128. states = { "Alabama", "Alaska", "Arizona", "Arkansas", "California", "Colorado", "Connecticut"}
  129. svar.set("Chose your location")
  130.  
  131. stateMenu = tk.OptionMenu(stateMainframe, svar, *states).grid(row = 3, column =1)
  132.  
  133. def state_dropdown(*args):
  134. print( svar.get() )
  135.  
  136. svar.trace('w', state_dropdown) #Which State
  137.  
  138. productMainframe = tk.Frame(self) #Which Product
  139. productMainframe.grid(row=4,column=1, sticky="W" )
  140. productMainframe.columnconfigure(0, weight = 1)
  141. productMainframe.rowconfigure(0, weight = 1)
  142. pvar = tk.StringVar(self)
  143.  
  144. products = { "Chairs", "Pens", "Televisions", "Desks", "Staplers", "Couches", "Laptops"}
  145. pvar.set("Chose your product")
  146.  
  147. productMenu = tk.OptionMenu(productMainframe, pvar, *products).grid(row = 4, column =1)
  148.  
  149. def product_dropdown(*args):
  150. print( pvar.get() )
  151.  
  152. pvar.trace('w', product_dropdown) #Which Product
  153.  
  154. yearMainframe = tk.Frame(self) #Which year
  155. yearMainframe.grid(row=5,column=1, sticky="W" )
  156. yearMainframe.columnconfigure(0, weight = 1)
  157. yearMainframe.rowconfigure(0, weight = 1)
  158. yvar = tk.IntVar(self)
  159.  
  160. years = { "2012", "2013", "2014", "2015", "2016", "2017", "2018"}
  161. yvar.set("Chose the year") # set the default option
  162.  
  163. yearMenu = tk.OptionMenu(yearMainframe, yvar, *years).grid(row = 5, column =1)
  164.  
  165. def year_dropdown(*args):
  166. print( yvar.get() )
  167.  
  168. yvar.trace('w', year_dropdown) #Which year
  169.  
  170.  
  171.  
  172. class Display(tk.Frame):
  173.  
  174. def __init__(self, parent, controller): #homepage
  175. tk.Frame.__init__(self,parent)
  176. self.configure(background="light grey")
  177. label = tk.Label(self, text="Profitable products", font=LARGE_FONT, bg="light grey").pack(pady=10)
  178.  
  179. listbox = tk.Listbox(self).pack()
  180.  
  181. #for i in range(20):
  182. #listbox.insert(END, str(i))
  183.  
  184. button = tk.Button(self, text="Back", bg="dark grey", fg="white",
  185. command=lambda: controller.show_frame(Deliverable1))
  186. button.pack(pady=7)
  187.  
  188.  
  189. app = Gui() #App is the object of the Gui class
  190. app.mainloop() # then run .mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement