Advertisement
Guest User

Untitled

a guest
Jul 15th, 2019
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.50 KB | None | 0 0
  1. import tkinter
  2. from itertools import cycle
  3. from tkinter import ttk
  4. from tkinter import *
  5. import threading
  6. import time
  7. import os, sys
  8. import sqlite3
  9.  
  10. class Homepage:
  11. def __init__(self, userID, order, cursor, conn):
  12. self.userID = userID
  13. self.order = order
  14. self.cursor = cursor
  15. self.conn = conn
  16.  
  17. #Variables
  18. self.Title1 = "PIZZA ORDER"
  19. self.background1 = "white"
  20. self.orders = []
  21.  
  22. self.HomeFile = Tk()
  23. self.HomeFile.title(self.Title1)
  24. self.HomeFile.wm_state("zoomed")
  25.  
  26. self.HomeFile.iconbitmap("logo.ico")
  27.  
  28. self.canvasWidth = self.HomeFile.winfo_screenheight()
  29. self.canvasHeight = self.HomeFile.winfo_screenwidth() - 50
  30.  
  31. self.Photo = PhotoImage(file="backgroundPizza.png")
  32. #self.HomeCanvas = Canvas(self.HomeFile, width=self.canvasWidth, height=self.canvasHeight)
  33.  
  34. self.HomeLabel = Label(self.HomeFile, image=self.Photo)
  35. self.HomeLabel.place(relx=0, rely=0)
  36.  
  37. self.HomepageFrame = Frame(self.HomeFile, background=self.background1, height=round((self.canvasHeight * 0.54) * 0.8), width=self.canvasWidth * 1.78)
  38. self.HomepageFrame.place(relx=.0, rely=.1)
  39.  
  40.  
  41. self.gameList = Frame(self.HomepageFrame, height=round(self.canvasHeight * 0.54 * 0.8), width=round((self.canvasWidth * 1.78) * 0.3))
  42. self.gameList.config(bg="#ebebeb")
  43. self.gameList.grid(row=0, column=0, rowspan=1, columnspan=1)
  44.  
  45. self.TitleLbl = Label(self.gameList, text=self.Title1, background=self.background1, foreground="black", font=("Impact", "50"))
  46. self.TitleLbl.grid(row=0, column=0, sticky="NSEW", columnspan=1)
  47.  
  48.  
  49. self.OrderButton = Button(self.gameList, text="ORDER A MEAL", font=("Eras Medium ITC", "30"), cursor="hand2", bd=0, command= lambda: self.SelectOption(0) )#, width=round((self.canvasWidth * 1.78) * 0.3), foreground="black", )
  50. self.OrderButton.config(relief=FLAT, fg="black", bg="#c8c8c8", activebackground="lightgray", activeforeground="white", justify="left")
  51. #self.OrderButton.config(hi)
  52. self.OrderButton.grid(row=1, column=0, sticky="NSEW", columnspan=1)
  53.  
  54. self.CheckOrderButton = Button(self.gameList, text="CHECK ORDER", font=("Eras Medium ITC", "30"), cursor="hand2", bd=0, command=lambda : self.SelectOption(1))#, width=round((self.canvasWidth * 1.78) * 0.3), foreground="black")
  55. self.CheckOrderButton.config(relief=FLAT, fg="black", bg="#c8c8c8", activebackground="lightgray", activeforeground="white", justify="left")
  56. self.CheckOrderButton.grid(row=2, column=0, sticky="NSEW", columnspan=1)
  57.  
  58. self.AccountDetailsButton = Button(self.gameList, text="ACCOUNT DETAILS", font=("Eras Medium ITC", "30"), cursor="hand2", bd=0, command=lambda: self.SelectOption(2))#, width=round((self.canvasWidth * 1.78) * 0.3), foreground="black")
  59. self.AccountDetailsButton.config(relief=FLAT, fg="black", bg="#c8c8c8", activebackground="lightgray", activeforeground="white", justify="left")
  60. self.AccountDetailsButton.grid(row=3, column=0, sticky="NSEW", columnspan=1)
  61.  
  62. self.Buttons = [self.OrderButton, self.CheckOrderButton, self.AccountDetailsButton]
  63.  
  64. self.PicImg = PhotoImage(file="slideShow1.png")
  65. self.SlideshowCanvas = Label(self.HomepageFrame, height=round(self.canvasHeight * 0.54 * 0.8), width=round((self.canvasWidth * 1.78) * 0.8), image=self.PicImg)
  66. self.SlideshowCanvas.grid(row=0, column=1, sticky="NSEW", columnspan=4)
  67.  
  68. self.createFrame()
  69.  
  70. self.photos = ["slideShow1.png", "slideShow2.png", "slideShow3.png"]
  71. self.PhotoImages = []
  72. self.x = 0
  73.  
  74. self.Photos = cycle((PhotoImage(file = image), image)
  75. for image in self.photos)
  76.  
  77.  
  78. threading.Thread(target=self.Slideshow, args=()).start()
  79. threading.Thread(target=self.HomeFile.mainloop(), args=()).start()
  80.  
  81. def Slideshow(self):
  82. imgObj, imgName = next(self.Photos)
  83. self.SlideshowCanvas.config(image=imgObj)
  84. self.SlideshowCanvas.after(1000, self.Slideshow)
  85.  
  86.  
  87. def createFrame(self):
  88. #FRAME 1
  89. self.Frame1 = Frame(self.HomepageFrame, height=round(self.canvasHeight * 0.54 * 0.8), width=round((self.canvasWidth * 1.78) * 0.8))
  90. self.Frame1.config(bg="#ebebeb")
  91.  
  92. self.OrderTitle = Label(self.Frame1, text="ORDER A PIZZA", font=("Calibri Light", "40", "bold"), bg="#ebebeb")
  93. self.OrderTitle.place(relx=.05, rely=.05)
  94.  
  95. self.ExitButton = Button(self.Frame1, text = " × ", font="Segoe 30 bold", bg="#0f0f0f", fg="#ebebeb", activebackground="#ebebeb", activeforeground="#0f0f0f")
  96. self.ExitButton.config(cursor="hand2", command= lambda: self.CloseF(self.Frames), bd=0)#, anchor=W)
  97. self.ExitButton.place(relx=.825, rely=.0)
  98.  
  99. self.OrdersFrame = Frame(self.Frame1, height=round(self.canvasHeight * 0.54 * 0.8* 0.8), width=round((self.canvasWidth * 1.78) * 0.8* 0.2))
  100. self.OrdersFrame.place(relx=.0, rely=.2)
  101.  
  102. self.TotalPriceFrame = Frame(self.OrdersFrame, bg="black", padx=10, pady=5, width=round((self.canvasWidth * 1.78) * 0.8* 0.2), height=900)
  103. self.TotalPriceFrame.place(relx=.0, rely=.9)
  104.  
  105. self.TotalPriceLabel = Label(self.TotalPriceFrame, text="£0.00", font=("Segoe UI", 15), justify=RIGHT, background="black", fg="white")
  106. self.TotalPriceLabel.config(justify=RIGHT, anchor=E, width=round((self.canvasWidth * 1.78) * 0.013))
  107. self.TotalPriceLabel.place(relx=.0, rely=.0)
  108.  
  109. if len(self.orders) == 0:
  110. self.NoOrders = Label(self.OrdersFrame, text="No orders", font=("Segoe UI", 12))
  111. self.NoOrders.place(relx=.3, rely=.4)
  112. else:
  113. for order in self.orders:
  114. i = self.orders.index(order)
  115. self.OrderLabel = Label(self.OrdersFrame, text=order, font=("Eras Medium ITC", 12), anchor=W, padx=15, pady=10)
  116. self.OrderLabel.grid(row=i, column=0, rowspan=1, columnspan=1)
  117.  
  118. #Frame where user will pick an order
  119. self.MealOrderFrame1 = Canvas(self.Frame1, width=round(self.canvasWidth), height=round(self.canvasHeight * 0.6))
  120. self.MealOrderFrame1.config(bg="white")#, padx=15, pady=50)
  121. #self.MealOrderFrame1.place(relx=.2, rely=.2)
  122.  
  123. self.MealOrderFrame2 = Frame(self.Frame1, width=round((self.canvasWidth * 1.78) * 0.8* 0.8), height=round(self.canvasHeight * 0.54 * 0.8* 0.8))
  124. self.MealOrderFrame2.config(bg="white")
  125.  
  126. self.MealOrderFrame3 = Frame(self.Frame1, width=round((self.canvasWidth * 1.78) * 0.8* 0.8), height=round(self.canvasHeight * 0.54 * 0.8* 0.8))
  127. self.MealOrderFrame3.config(bg="white")
  128.  
  129. #CONTINUE HERE
  130. PhotoImages = []
  131. self.cursor.execute('SELECT * FROM PizzaCrust')
  132. crusts = self.cursor.fetchall()
  133.  
  134. for crust in crusts:
  135. flieDir = os.getcwd()
  136. i = crusts.index(crust)
  137. print(crust[3])
  138. CrustPhotoImage = PhotoImage(file="thickCrust.png")
  139. PhotoImages.append(CrustPhotoImage)
  140.  
  141. print(PhotoImages)
  142.  
  143. #i = crusts.index(crust )
  144. crustButton = Label(self.Frame1, image=PhotoImage(file="thinCrust.png"))
  145. crustButton.place(relx=.1, rely=.1)
  146.  
  147. #self.MealOrderFrame1.create_image(0,0, image=PhotoImage("thinCrust.png"))
  148.  
  149.  
  150.  
  151. #FRAME 2
  152. self.Frame2 = Frame(self.HomepageFrame, height=round(self.canvasHeight * 0.54 * 0.8), width=round((self.canvasWidth * 1.78) * 0.8))
  153. self.Frame2.config(bg="#ebebeb")
  154.  
  155. self.OrderTitle2 = Label(self.Frame2, text="CHECK ORDER", font=("Calibri Light", "40", "bold"), bg="#ebebeb")
  156. self.OrderTitle2.place(relx=.05, rely=.05)
  157.  
  158. self.ExitButton = Button(self.Frame2, text = " × ", font=("Segoe UI", "30", "bold"), bg="#0f0f0f", fg="#ebebeb", activebackground="#ebebeb", activeforeground="#0f0f0f")
  159. self.ExitButton.config(cursor="hand2", command= lambda: self.CloseF(self.Frames), bd=0)#, anchor=W)
  160. self.ExitButton.place(relx=.825, rely=.0)
  161.  
  162. #FRAME 3
  163. self.Frame3 = Frame(self.HomepageFrame, height=round(self.canvasHeight * 0.54 * 0.8), width=round((self.canvasWidth * 1.78) * 0.8))
  164. self.Frame3.config(bg="#ebebeb")
  165.  
  166. self.OrderTitle3 = Label(self.Frame3, text="ACCOUNT SETTINGS", font=("Calibri Light", "40", "bold"), bg="#ebebeb")
  167. self.OrderTitle3.place(relx=.05, rely=.05)
  168.  
  169. self.ExitButton = Button(self.Frame3, text = " × ", font=("Segoe", "30", "bold"), bg="#0f0f0f", fg="#ebebeb", activebackground="#ebebeb", activeforeground="#0f0f0f")
  170. self.ExitButton.config(cursor="hand2", command=lambda: self.CloseF(self.Frames), bd=0)#, anchor=W)
  171. self.ExitButton.place(relx=.825, rely=.0)
  172.  
  173.  
  174.  
  175. self.Frames = [self.Frame1, self.Frame2, self.Frame3]
  176.  
  177. def SelectOption(self, i):
  178. for x in range(0, 3):
  179. try:
  180. self.Frames[x].grid_forget()
  181. self.Buttons[x].config(fg="black")
  182. except:
  183. pass
  184. self.Frames[i].grid(row=0, column=1, sticky="NSEW", columnspan=4)
  185. self.Buttons[i].config(fg="white")
  186.  
  187. def CloseF(self, frames):
  188. for x in range(0, 3):
  189. try:
  190. frames[x].grid_forget()
  191. self.Buttons[x].config(fg="black")
  192. except ImportError:
  193. pass
  194.  
  195. conn = sqlite3.connect("Pizza.db")
  196. cursor = conn.cursor()
  197.  
  198. if __name__ in '__main__':
  199. Homepage("dakinfemiwa", 0, cursor, conn)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement