From ef780a93fef6136537d34bba54bdb065db440b6a Mon Sep 17 00:00:00 2001 From: pyau6ffc2 <2075227361@qq.com> Date: Fri, 31 May 2024 18:09:05 +0800 Subject: [PATCH] ADD file via upload --- MainPage.py | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 MainPage.py diff --git a/MainPage.py b/MainPage.py new file mode 100644 index 0000000..3cd45ba --- /dev/null +++ b/MainPage.py @@ -0,0 +1,75 @@ +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() +