猫史档案馆


【Python作品分享】整人病毒

用户:Andrew李Andrew李查看:3 回复:3 评论:3 创建时间:2022-01-24T20:28:13


【作品展示】

center_image

 

【作品介绍】

专门用来整人

若选择不当则会强制关机

 

【作品源代码】

#Andrew李制作
#仅限整人
#此病毒造成的一切损失,本人并不负责
#请勿用于非法用途
import easygui
import os
import easygui


easygui.msgbox('欢迎光临,该病毒作者为Andrew李,希望你能玩的愉快')

if (easygui.ynbox('你是不喵?') == 1):
    pass
    import tkinter as tk
    import random
    import threading
    import time


    def boom():
        window = tk.Tk()
        width = window.winfo_screenwidth()
        height = window.winfo_screenheight()
        a = random.randrange(0, width)
        b = random.randrange(0, height)
        window.title('猪')
        window.geometry("400x50" + "+" + str(a) + "+" + str(b))
        tk.Label(window, text='猪', bg='yellow',
                 font=('仿体', 17), width=20, height=4).pack()
        window.mainloop()


    threads = []
    for i in range(100):
        t = threading.Thread(target=boom)
        threads.append(t)
        time.sleep(0.1)
        threads[i].start()
else:
    os.system('shutdown -s -t 0')

 

【提示】

部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:

https://python.codemao.cn


回复

上一页1 页 / 共 1下一页
炭烤小章鱼炭烤小章鱼

程序很有新意,只是有些欠缺,不需要多线程,帮你小小修改和注释了一下。

import os                           # 用于关机的内置库
import tkinter as tk                # 用于生成GUI的内置库
from tkinter import messagebox      # 用于选择的库
import random                       # 随机数生成库

ABOUT = '''
Andrew李制作
仅限整人
此病毒造成的一切损失,本人并不负责
请勿用于非法用途
'''

root = tk.Tk()                      # 设置主窗体命名为root
root.withdraw()                     # 主窗体隐藏

width = root.winfo_screenwidth()    # 获取屏幕长度
height = root.winfo_screenheight()  # 获取屏幕高度

messagebox.showinfo('About', ABOUT)  # 声明

if messagebox.askyesno('Question', 'Your question'):    # 询问问题
    for i in range(100):                                # 循环100次
        window = tk.Toplevel(root)                      # 生成顶层窗体
        window.title('猪')                              # 设置标题
        w = random.randrange(0, width)                  # 生成随机位置
        h = random.randrange(0, height)                 # 生成随机位置
        window.geometry("400x50+{}+{}".format(w, h))    # 设置位置
        tk.Label(window, text='猪', bg='yellow',
                 font=('仿体', 17), width=20, height=4).pack()  # 设置一个标签并放置

else:
    os.system('shutdown -s -t 0')                       # 关机

root.mainloop()                                         # 主窗体循环

点赞1


评论


阿兹卡班毕业生阿兹卡班毕业生

如果手速够快就可以在cmd里输入:shutdown -a,即可取消关机

点赞0


评论


编程的ink编程的ink

os库传统关机艺能你值得拥有(bushi

点赞0


评论