Advertisement
Guest User

try this

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