Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import tkinter
- from itertools import cycle
- from tkinter import ttk
- from tkinter import *
- import threading
- import time
- import os, sys
- import sqlite3
- class Homepage:
- def __init__(self, userID, order, cursor, conn):
- self.userID = userID
- self.order = order
- self.cursor = cursor
- self.conn = conn
- #Variables
- self.Title1 = "PIZZA ORDER"
- self.background1 = "white"
- self.orders = []
- self.HomeFile = Tk()
- self.HomeFile.title(self.Title1)
- self.HomeFile.wm_state("zoomed")
- self.HomeFile.iconbitmap("logo.ico")
- self.canvasWidth = self.HomeFile.winfo_screenheight()
- self.canvasHeight = self.HomeFile.winfo_screenwidth() - 50
- self.Photo = PhotoImage(file="backgroundPizza.png")
- #self.HomeCanvas = Canvas(self.HomeFile, width=self.canvasWidth, height=self.canvasHeight)
- self.HomeLabel = Label(self.HomeFile, image=self.Photo)
- self.HomeLabel.place(relx=0, rely=0)
- self.HomepageFrame = Frame(self.HomeFile, background=self.background1, height=round((self.canvasHeight * 0.54) * 0.8), width=self.canvasWidth * 1.78)
- self.HomepageFrame.place(relx=.0, rely=.1)
- self.gameList = Frame(self.HomepageFrame, height=round(self.canvasHeight * 0.54 * 0.8), width=round((self.canvasWidth * 1.78) * 0.3))
- self.gameList.config(bg="#ebebeb")
- self.gameList.grid(row=0, column=0, rowspan=1, columnspan=1)
- self.TitleLbl = Label(self.gameList, text=self.Title1, background=self.background1, foreground="black", font=("Impact", "50"))
- self.TitleLbl.grid(row=0, column=0, sticky="NSEW", columnspan=1)
- 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", )
- self.OrderButton.config(relief=FLAT, fg="black", bg="#c8c8c8", activebackground="lightgray", activeforeground="white", justify="left")
- #self.OrderButton.config(hi)
- self.OrderButton.grid(row=1, column=0, sticky="NSEW", columnspan=1)
- 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")
- self.CheckOrderButton.config(relief=FLAT, fg="black", bg="#c8c8c8", activebackground="lightgray", activeforeground="white", justify="left")
- self.CheckOrderButton.grid(row=2, column=0, sticky="NSEW", columnspan=1)
- 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")
- self.AccountDetailsButton.config(relief=FLAT, fg="black", bg="#c8c8c8", activebackground="lightgray", activeforeground="white", justify="left")
- self.AccountDetailsButton.grid(row=3, column=0, sticky="NSEW", columnspan=1)
- self.Buttons = [self.OrderButton, self.CheckOrderButton, self.AccountDetailsButton]
- self.PicImg = PhotoImage(file="slideShow1.png")
- self.SlideshowCanvas = Label(self.HomepageFrame, height=round(self.canvasHeight * 0.54 * 0.8), width=round((self.canvasWidth * 1.78) * 0.8), image=self.PicImg)
- self.SlideshowCanvas.grid(row=0, column=1, sticky="NSEW", columnspan=4)
- self.createFrame()
- self.photos = ["slideShow1.png", "slideShow2.png", "slideShow3.png"]
- self.PhotoImages = []
- self.x = 0
- self.Photos = cycle((PhotoImage(file = image), image)
- for image in self.photos)
- threading.Thread(target=self.Slideshow, args=()).start()
- threading.Thread(target=self.HomeFile.mainloop(), args=()).start()
- def Slideshow(self):
- imgObj, imgName = next(self.Photos)
- self.SlideshowCanvas.config(image=imgObj)
- self.SlideshowCanvas.after(1000, self.Slideshow)
- def createFrame(self):
- #FRAME 1
- self.Frame1 = Frame(self.HomepageFrame, height=round(self.canvasHeight * 0.54 * 0.8), width=round((self.canvasWidth * 1.78) * 0.8))
- self.Frame1.config(bg="#ebebeb")
- self.OrderTitle = Label(self.Frame1, text="ORDER A PIZZA", font=("Calibri Light", "40", "bold"), bg="#ebebeb")
- self.OrderTitle.place(relx=.05, rely=.05)
- self.ExitButton = Button(self.Frame1, text = " × ", font="Segoe 30 bold", bg="#0f0f0f", fg="#ebebeb", activebackground="#ebebeb", activeforeground="#0f0f0f")
- self.ExitButton.config(cursor="hand2", command= lambda: self.CloseF(self.Frames), bd=0)#, anchor=W)
- self.ExitButton.place(relx=.825, rely=.0)
- 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))
- self.OrdersFrame.place(relx=.0, rely=.2)
- self.TotalPriceFrame = Frame(self.OrdersFrame, bg="black", padx=10, pady=5, width=round((self.canvasWidth * 1.78) * 0.8* 0.2), height=900)
- self.TotalPriceFrame.place(relx=.0, rely=.9)
- self.TotalPriceLabel = Label(self.TotalPriceFrame, text="£0.00", font=("Segoe UI", 15), justify=RIGHT, background="black", fg="white")
- self.TotalPriceLabel.config(justify=RIGHT, anchor=E, width=round((self.canvasWidth * 1.78) * 0.013))
- self.TotalPriceLabel.place(relx=.0, rely=.0)
- if len(self.orders) == 0:
- self.NoOrders = Label(self.OrdersFrame, text="No orders", font=("Segoe UI", 12))
- self.NoOrders.place(relx=.3, rely=.4)
- else:
- for order in self.orders:
- i = self.orders.index(order)
- self.OrderLabel = Label(self.OrdersFrame, text=order, font=("Eras Medium ITC", 12), anchor=W, padx=15, pady=10)
- self.OrderLabel.grid(row=i, column=0, rowspan=1, columnspan=1)
- #Frame where user will pick an order
- self.MealOrderFrame1 = Canvas(self.Frame1, width=round(self.canvasWidth), height=round(self.canvasHeight * 0.6))
- self.MealOrderFrame1.config(bg="white")#, padx=15, pady=50)
- #self.MealOrderFrame1.place(relx=.2, rely=.2)
- 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))
- self.MealOrderFrame2.config(bg="white")
- 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))
- self.MealOrderFrame3.config(bg="white")
- #CONTINUE HERE
- PhotoImages = []
- self.cursor.execute('SELECT * FROM PizzaCrust')
- crusts = self.cursor.fetchall()
- for crust in crusts:
- flieDir = os.getcwd()
- i = crusts.index(crust)
- print(crust[3])
- CrustPhotoImage = PhotoImage(file="thickCrust.png")
- PhotoImages.append(CrustPhotoImage)
- print(PhotoImages)
- #i = crusts.index(crust )
- crustButton = Label(self.Frame1, image=PhotoImage(file="thinCrust.png"))
- crustButton.place(relx=.1, rely=.1)
- #self.MealOrderFrame1.create_image(0,0, image=PhotoImage("thinCrust.png"))
- #FRAME 2
- self.Frame2 = Frame(self.HomepageFrame, height=round(self.canvasHeight * 0.54 * 0.8), width=round((self.canvasWidth * 1.78) * 0.8))
- self.Frame2.config(bg="#ebebeb")
- self.OrderTitle2 = Label(self.Frame2, text="CHECK ORDER", font=("Calibri Light", "40", "bold"), bg="#ebebeb")
- self.OrderTitle2.place(relx=.05, rely=.05)
- self.ExitButton = Button(self.Frame2, text = " × ", font=("Segoe UI", "30", "bold"), bg="#0f0f0f", fg="#ebebeb", activebackground="#ebebeb", activeforeground="#0f0f0f")
- self.ExitButton.config(cursor="hand2", command= lambda: self.CloseF(self.Frames), bd=0)#, anchor=W)
- self.ExitButton.place(relx=.825, rely=.0)
- #FRAME 3
- self.Frame3 = Frame(self.HomepageFrame, height=round(self.canvasHeight * 0.54 * 0.8), width=round((self.canvasWidth * 1.78) * 0.8))
- self.Frame3.config(bg="#ebebeb")
- self.OrderTitle3 = Label(self.Frame3, text="ACCOUNT SETTINGS", font=("Calibri Light", "40", "bold"), bg="#ebebeb")
- self.OrderTitle3.place(relx=.05, rely=.05)
- self.ExitButton = Button(self.Frame3, text = " × ", font=("Segoe", "30", "bold"), bg="#0f0f0f", fg="#ebebeb", activebackground="#ebebeb", activeforeground="#0f0f0f")
- self.ExitButton.config(cursor="hand2", command=lambda: self.CloseF(self.Frames), bd=0)#, anchor=W)
- self.ExitButton.place(relx=.825, rely=.0)
- self.Frames = [self.Frame1, self.Frame2, self.Frame3]
- def SelectOption(self, i):
- for x in range(0, 3):
- try:
- self.Frames[x].grid_forget()
- self.Buttons[x].config(fg="black")
- except:
- pass
- self.Frames[i].grid(row=0, column=1, sticky="NSEW", columnspan=4)
- self.Buttons[i].config(fg="white")
- def CloseF(self, frames):
- for x in range(0, 3):
- try:
- frames[x].grid_forget()
- self.Buttons[x].config(fg="black")
- except ImportError:
- pass
- conn = sqlite3.connect("Pizza.db")
- cursor = conn.cursor()
- if __name__ in '__main__':
- Homepage("dakinfemiwa", 0, cursor, conn)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement