# -*- coding: utf-8 -*- # @Version: Python 3.9 # @Time : 2022/5/11 10:05 # @Author : chenyinhua # @File : alertlover.py # @Software: PyCharm # @Desc: windows弹窗显示爱心 import time import random import threading import tkinter as tk import time def lover(): """ 返回爱心 :return: """ target = "♥" for char in target.split(): all_char = [] for y in range(12, -12, -1): lst = [] lst_con = "" for x in range(-30, 30): formula = ((x * 0.05) ** 2 + (y * 0.1) ** 2 - 1) ** 3 - (x * 0.05) ** 2 * (y * 0.1) ** 3 if formula <= 0: lst_con += char[x % len(char)] else: lst_con += " " lst.append(lst_con) all_char += lst time.sleep(1) return "\n".join(all_char) def boom(): """ 爆炸弹窗 :return: """ window = tk.Tk() window.title("今天是友爱的一天") # 弹窗位置随机 # width = window.winfo_screenwidth() # height = window.winfo_screenheight() # a = random.randrange(0, width) # b = random.randrange(0, height) # window.geometry("860x600+10+10" + "+" + str(a) + "+" + str(b)) # 弹窗位置 距离上100 距离左100 window.geometry("860x600+100+100") tk.Label(window, text=lover(), bg="white", font=("宋体", 17), fg="red", width=150, height=40).pack() window.mainloop() if __name__ == '__main__': boom()