from tkinter import * def button_click(): window.destroy() # 关闭当前窗口 import main # 导入主界面的代码 window = Tk() window.title("欢迎界面") label_welcome = Label(window, text="欢迎帅哥美女来到身体健康数据检测", font=("Arial", 20)) label_welcome.pack(pady=20) button = Button(window, text="点击进入首页", command=button_click) button.pack(pady=10) button.place(relx=0.5, rely=0.5, anchor=CENTER) # 将按钮放在窗口中间 screen_width = window.winfo_screenwidth() screen_height = window.winfo_screenheight() window_width = int(screen_width / 2) window_height = int(screen_height / 2) x = (screen_width - window_width) // 2 y = (screen_height - window_height) // 2 window.geometry("{}x{}+{}+{}".format(window_width, window_height, x, y)) window.mainloop()