From ccc02b3b4492d1c61c9d94588a598797d0f6cd1c Mon Sep 17 00:00:00 2001 From: pzyexn7bj <2558997203@qq.com> Date: Fri, 31 May 2024 10:34:07 +0800 Subject: [PATCH] =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E4=B8=BB=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 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..b3b5d50 --- /dev/null +++ b/MainPage.py @@ -0,0 +1,75 @@ +import tkinter as tk +from Views import AboutFrame, AddFrame, ChangeFrame, SearchFrame, DeleteFrame + + +class MainPage: + def __init__(self, master): + self.root = master + self.root.title("文章管理系统") + self.root.geometry("500x500+520+170") + + self.about_frame = AboutFrame(self.root) + self.add_frame = AddFrame(self.root) + self.change_frame = ChangeFrame(self.root) + self.search_frame = SearchFrame(self.root) + self.delete_frame = DeleteFrame(self.root) + self.create_page() + self.show_search() + + def create_page(self): + menubar = tk.Menu(self.root) + # 注意这些show_xxx的代码应该要优化的 + menubar.add_command(label='添加', command=self.show_add) + menubar.add_command(label='修改', command=self.show_change) + menubar.add_command(label='查询', command=self.show_search) + menubar.add_command(label='删除', command=self.show_delete) + menubar.add_command(label='关于', command=self.show_about) + # self.root.config(menu=menubar) + self.root['menu'] = menubar + + def show_about(self): + self.about_frame.pack() + self.add_frame.pack_forget() + self.change_frame.pack_forget() + self.search_frame.pack_forget() + self.delete_frame.pack_forget() + self.root.geometry("500x150+520+230") + + def show_add(self): + self.about_frame.pack_forget() + self.add_frame.pack() + self.change_frame.pack_forget() + self.search_frame.pack_forget() + self.delete_frame.pack_forget() + self.root.geometry("500x500+520+170") + + def show_change(self): + self.about_frame.pack_forget() + self.add_frame.pack_forget() + self.change_frame.pack() + self.search_frame.pack_forget() + self.delete_frame.pack_forget() + self.root.geometry("500x550+520+120") + + + def show_search(self): + self.about_frame.pack_forget() + self.add_frame.pack_forget() + self.change_frame.pack_forget() + self.search_frame.pack() + self.delete_frame.pack_forget() + self.root.geometry("500x500+520+170") + + def show_delete(self): + self.about_frame.pack_forget() + self.add_frame.pack_forget() + self.change_frame.pack_forget() + self.search_frame.pack_forget() + self.delete_frame.pack() + self.root.geometry("500x150+520+230") + + +if __name__ == "__main__": + root = tk.Tk() + MainPage(root) + root.mainloop()