import tkinter as tk
from tkinter import messagebox
root = tk.Tk()
root.title("真的假条✉")
root.resizable(False, False)
root.wm_attributes("-toolwindow", 1)
screenwidth = root.winfo_screenwidth()
screenheight = root.winfo_screenheight()
width, height = 500, 120
x = (screenwidth - width) / 2
y = (screenheight - height) / 2
root.geometry('%dx%d+%d+%d' % (width, height, x, y)) # 设置在屏幕中居中显示
tk.Label(root, text="老师,今天身体不舒服,请个假呗(●ˇ∀ˇ●)", width=50, font='黑体').pack(pady='5')
def yes(): # 同意按钮
messagebox.showinfo("o(* ̄▽ ̄*)ブ", "感谢老师!!!") # 弹出信息对话框
root.destroy() # 同意后退出窗口
def no(): # 拒绝按钮
messagebox.showinfo("/(ㄒoㄒ)/~~", "身体真的不舒服~") # 弹出信息对话框
def close_window(): # 关闭按钮
messagebox.showinfo("/(ㄒoㄒ)/~~", "您就让我休息吧~") # 弹出信息对话框
tk.Button(root, text=" 必须的!", width=10, font=('黑体', 12), height=1, command=yes).pack(pady='5')
tk.Button(root, text=" 休想!", width=10, font=('黑体', 12), height=1, command=no).pack(pady='5')
root.protocol('WM_DELETE_WINDOW', close_window) # 绑定关闭事件
root.mainloop()