Search code examples
pythontkintermalware

How to make tkinter show multiple warnings in python, and how to make a python script uncloseable?


I want to prank my friends, by making a script, that keeps displaying a warning, and is completely un-closeable. My code so far is:

import tkinter as tk
from tkinter import messagebox
import random
root = tk.Tk()

messages=["Anodr settlument neds yer hulp!","Another settlement needs your help!",
          "Settlument another help needs!","Need hulp settlement!","Anuthr settlumet neeedl yur halp!"]

def on_closing():
    pass

root.protocol("WM_DELETE_WINDOW", on_closing)

while True(5):
    messagebox.showwarning("Prstn",messages[random.randint(0,4)])

root.mainloop()

The problem is, that this can still be closed, if you close the CMD window, that opens when you start the program. How can I counteract this? If there is no solution, how can I adapt my program, so that it displays a bunch of warnings at once, that floods your screen?


Solution

  • Turn the message into a question, then just keep asking stupid questions...not recommended though, they might not be your friend anymore.

    yn = tkMessageBox.askyesno("Text", "Ask a question...")
    if yn == True:
        yn = tkMessageBox.askyesno("Text", "Ask another question...")
        if yn == True:
            yn = tkMessageBox.askyesno("Text", "Ask another question...")
            ...
            ...
    else:
        yn = tkMessageBox.askyesno("Text", "Ask another question...")
        if yn == True:
            yn = tkMessageBox.askyesno("Text", "Ask another question...")
        else:
            ...
            ...