新的一年,用python来写封辞职信告别坏运气

嗨害大家好鸭!我是小熊猫~

2023也是继续不想工作的一年呢~

那就简单来用python写一封辞职信来和他们告别吧~

都2023年了,未来还有诗和远方


演示效果【文末名片获取源码】

请添加图片描述

所需模块

import random
import tkinter as tk
from tkinter import messagebox
from PIL import Image, ImageTk

关闭窗口关不掉

def closeWindow():
    messagebox.showinfo(title="不同意关不掉", message="不同意可关不掉喔~")
    return

在这里插入图片描述

同意关闭

def agree():
    win = tk.Toplevel(window)
    win.geometry("500x150+{}+{}".
                 format(int((screenwidth - width) / 4),
                        int((screenheight - height) / 4)))
    win.title("辞职溜了再见!")
    label = tk.Label(win, text="您耗子尾汁,大吉大利", font=("幼圆", 20))
    label.pack()
    btn = tk.Button(win, text="慢走不送", width=8, height=2, command=window.destroy)
    btn.pack()

在这里插入图片描述

一些窗口参数

def disagree():
    B2.place_forget()
    B2.place(x=random.randint(100, 500), y=random.randint(100, 500))

在这里插入图片描述

if __name__ == '__main__':
    window = tk.Tk()
    window.title('辞职信')
    width = 600
    height = 650
    alignstr = '%dx%d+%d+%d' % 
    window.resizable(width=False, height=True)
    window.geometry('600x600')
    window.protocol("WM_DELETE_WINDOW", closeWindow)
    load = Image.open('02.jpeg').resize((300, 310))
    render = ImageTk.PhotoImage(load)
    L2 = tk.Label(window, image=render)
    L2.place(x=150, y=100)
    B1 = tk.Button(window, text='同意', command=agree)
    B1.place(x=155, y=420)
    B2 = tk.Button(window, text='不同意', command=disagree)
    B2.place(x=400, y=420)
    window.mainloop()

在这里插入图片描述

今天的文章就是这样啦~

我是小熊猫,咱下篇文章再见啦~

猜你喜欢

转载自blog.csdn.net/m0_67575344/article/details/128645589
今日推荐