所以,我试着在蟒蛇中复制“你是个白痴”病毒。我这样做的方式是循环我的python脚本。我试着做到这样,当你试图关闭窗口时,会出现更多的弹出窗口。
这是第一次工作,但后来,我开始得到这个错误的_tkinter.TclError: can't invoke "wm" command: application has been destroyed,我无法找到一个方法来修复它。这是我如何得到这个错误的代码。
另外,我需要循环的另一个原因是,我使用random函数使窗口出现在随机位置。
# On closing function:
def on_closing():
restart()
root.protocol("WM_DELETE_WINDOW", on_closing)
root.title("you are an idiot")
root.mainloop()
# Restart function:
def restart():
os.system("python3 main.py")
Random position functions:
#random values
x = random.randint(100,600)
y = random.randint(200,600)
root.geometry("+{}+{}".format(x,y)) #randomized window position发布于 2022-04-19 07:39:47
您可以将事件绑定用于销毁事件。
root.bind("<Destroy>", on_closing)您向main.py显示的代码是吗?
https://stackoverflow.com/questions/71917396
复制相似问题