-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtools.py
43 lines (28 loc) · 1.04 KB
/
tools.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
import tkinter
from PIL import ImageTk, Image
def make_popup():
""" Make a popup window with an image. """
# basic object that represents the window
root = tkinter.Tk()
# widget for storing the actual image
img = ImageTk.PhotoImage(Image.open("Pics\chill.jpg"))
widget = tkinter.Label(root, image=img)
widget.pack()
# make window popup on top; make window disappear after 1,5s
root.attributes("-topmost", True)
root.after(1500, lambda: root.destroy())
root.mainloop()
class TextAnalyzer:
""" Object to analyze the text and based on the result call an appropriate function. """
def __init__(self):
# define your set of bad words
self.bw_set = set()
with open('Bad_words/bad_words_eng.txt', mode='r') as f:
for line in f:
self.bw_set.add(line.replace('\n', ''))
def analyze_text(self, text):
""" Check the text and call function. """
if text.lower() in self.bw_set:
make_popup()
else:
print(text)