5.10号今日总结

今日代码:

from tkinter import *
import tkinter.font as tkFont
import tkinter as tk
from tkinter import ttk
LARGE_FONT= ("Verdana", 20)

class Application(tk.Tk):
    def __init__(self):

        super().__init__()

        self.wm_title("学生信息管理系统")

        container = tk.Frame(self)
        container.pack(side="top", fill="both", expand = True)
        container.grid_rowconfigure(0, weight=1)
        container.grid_columnconfigure(0, weight=1)

        self.frames = {}
        #循环功能界面
        for F in (StartPage, PageOne, PageTwo, PageThree,PageFour):
            frame = F(container, self)
            self.frames[F] = frame
            frame.grid(row=0, column=0, sticky="nsew")  # 四个页面的位置都是 grid(row=0, column=0), 位置重叠,只有最上面的可见!!

        self.show_frame(StartPage)


    def show_frame(self, cont):
        frame = self.frames[cont]
        frame.tkraise() # 切换,提升当前 tk.Frame z轴顺序(使可见)!!此语句是本程序的点睛之处
        
        #主页面
class StartPage(tk.Frame):
    '''主页'''
    def __init__(self, parent, root):
        super().__init__(parent)
        label = tk.Label(self, text="学生信息管理系统", font=LARGE_FONT)
        label.pack(pady=100)
        ft2=tkFont.Font(size=16)
        Button(self, text="添加学生信息",font=ft2,command=lambda: root.show_frame(PageOne),width=30,height=2,fg='white',bg='gray',activebackground='black',activeforeground='white').pack()
        Button(self, text="删除学生信息",font=ft2,command=lambda: root.show_frame(PageTwo),width=30,height=2).pack()
        Button(self, text="修改学生信息",font=ft2,command=lambda: root.show_frame(PageThree),width=30,height=2,fg='white',bg='gray',activebackground='black',activeforeground='white').pack()
        Button(self, text="查询学生信息",font=ft2,command=lambda: root.show_frame(PageFour),width=30,height=2).pack()
        Button(self,text='退出系统',height=2,font=ft2,width=30,command=root.destroy,fg='white',bg='gray',activebackground='black',activeforeground='white').pack()
        

 

posted @ 2023-05-10 23:10  庞司令  阅读(24)  评论(0)    收藏  举报