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()