You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
76 lines
2.7 KiB
76 lines
2.7 KiB
import tkinter as tk
|
|
from views import CakeFrame,BreadFrame,ToastFrame,BiscuitsFrame,PuffFrame
|
|
from PIL import Image, ImageTk
|
|
class MainPage:
|
|
def __init__(self,master:tk.Tk):
|
|
self.root = master
|
|
self.root.title('配置中')
|
|
self.root.geometry('600x400')
|
|
self.create_page()
|
|
|
|
def create_page(self):
|
|
self.cake_frame = CakeFrame(self.root)
|
|
self.bread_frame = BreadFrame(self.root)
|
|
self.toast_frame = ToastFrame(self.root)
|
|
self.biscuits_frame = BiscuitsFrame(self.root)
|
|
self.puff_frame = PuffFrame(self.root)
|
|
|
|
menubar = tk.Menu(self.root)
|
|
menubar.add_command(label='欢迎光临', command=self.show_bread)
|
|
menubar.add_command(label='蛋糕',command=self.show_cake)
|
|
menubar.add_command(label='修改商品',command=self.show_toast)
|
|
menubar.add_command(label='删除商品',command=self.show_biscuits)
|
|
menubar.add_command(label='加货',command=self.show_puff)
|
|
self.root['menu'] = menubar
|
|
|
|
def show_bread(self):
|
|
self.bread_frame.pack()
|
|
self.cake_frame.pack_forget()
|
|
self.toast_frame.pack_forget()
|
|
self.biscuits_frame.pack_forget()
|
|
self.puff_frame.pack_forget()
|
|
|
|
self.canvas = tk.Canvas(self.root, width=1080, height=680)
|
|
self.canvas.pack()
|
|
|
|
# 加载背景图片
|
|
self.bg_image = Image.open('G:\\design\\pythonProject\\cake.gif')
|
|
self.bg_photo = ImageTk.PhotoImage(self.bg_image)
|
|
self.canvas.create_image(0, 0, anchor=tk.NW, image=self.bg_photo)
|
|
|
|
def show_cake(self):
|
|
self.cake_frame.pack()
|
|
self.bread_frame.pack_forget()
|
|
self.toast_frame.pack_forget()
|
|
self.biscuits_frame.pack_forget()
|
|
self.puff_frame.pack_forget()
|
|
self.canvas.pack_forget()
|
|
def show_toast(self):
|
|
self.toast_frame.pack()
|
|
self.cake_frame.pack_forget()
|
|
self.bread_frame.pack_forget()
|
|
self.biscuits_frame.pack_forget()
|
|
self.puff_frame.pack_forget()
|
|
self.canvas.pack_forget()
|
|
def show_biscuits(self):
|
|
self.biscuits_frame.pack()
|
|
self.cake_frame.pack_forget()
|
|
self.bread_frame.pack_forget()
|
|
self.toast_frame.pack_forget()
|
|
self.puff_frame.pack_forget()
|
|
self.canvas.pack_forget()
|
|
def show_puff(self):
|
|
self.puff_frame.pack()
|
|
self.cake_frame.pack_forget()
|
|
self.bread_frame.pack_forget()
|
|
self.toast_frame.pack_forget()
|
|
self.biscuits_frame.pack_forget()
|
|
self.canvas.pack_forget()
|
|
|
|
|
|
if __name__ == '__main__':
|
|
root =tk.Tk()
|
|
MainPage(root)
|
|
root.mainloop()
|
|
|