
import tkinter as tk
from tkinter import messagebox
from random import random
window = tk.Tk()
window.resizable(False, False)
screen_width = window.winfo_screenwidth()
screen_height = window.winfo_screenheight()
window_width = 500
window_height = 300
x = (screen_width // 2) - (window_width // 2)
y = (screen_height // 2) - (window_height // 2)
window.geometry(f'{window_width}x{window_height}+{x}+{y}')
window.title('辞职信')
frame1 = tk.Frame(window)
frame1.pack()
tk.Label(frame1, text='尊敬的各位领导:', font=24, padx=30, pady=30).pack(side=tk.LEFT, anchor=tk.N)
img = tk.PhotoImage(file='down.png')
img = img.subsample(2, 2)
label_img = tk.Label(frame1, image=img, padx=30, pady=30, bd=0)
label_img.pack(side=tk.LEFT, anchor=tk.N)
tk.Label(frame1, text='辞职人:小帅', height=25, font=24, padx=10, pady=10, anchor=tk.S).pack(side=tk.LEFT)
yes_btn = tk.Button(frame1, text='同意', bd=0, width=6, height=1, bg='red')
no_btn = tk.Button(frame1, text='不同意', bd=0, width=6, height=1, bg='red')
yes_btn.place(relx=0.3, rely=0.7, anchor=tk.CENTER)
no_btn.place(relx=0.7, rely=0.7, anchor=tk.CENTER)
frame2 = tk.Frame(window)
tk.Label(frame2, text='再见!这破班不上也罢!!!', font=('黑体', 18), justify=tk.LEFT, height=300, fg='red', padx=50).pack()
tk.Button(frame2, text='退出', command=window.quit).place(relx=0.9, rely=0.8)
def on_exit():messagebox.showwarning(title='提示', message='此路不通')
window.protocol('WM_DELETE_WINDOW', on_exit)
def move(event):no_btn.place(relx=random(), rely=random(), anchor=tk.CENTER)
no_btn.bind('<Enter>', move)
def sure():frame1.pack_forget() frame2.pack()
yes_btn.config(command=sure)
window.mainloop()