Amazing-Python-Scripts
50 строк · 1.4 Кб
1from tkinter import *
2from tkinter import messagebox
3import Model
4
5
6def search():
7word = enterWordEntry.get()
8
9text = word.strip()
10messagebox.showinfo("Input", " Input = "+text)
11model_object = Model.model()
12
13if word != "" and word != " " and word is not None:
14sentiment = model_object.get_sentimental_analysis(text)
15messagebox.showinfo("Result", sentiment)
16
17else:
18messagebox.showerror('Error', 'Invalid Input.Please double check it.')
19enterWordEntry.delete(0, END)
20
21
22root = Tk()
23
24root.geometry("1280x720+1000+30")
25
26root.title("Text Sentimental Analysis")
27
28root.resizable(False, False)
29
30image = PhotoImage(
31file="./Text_Sentimental_Analysis_Script_with_GUI/images/background.png")
32image_label = Label(root, image=image)
33image_label.place(x=0, y=0)
34
35enterWordLabel = Label(root, text='Enter Text for Analysis',
36font=('castellar', 15, 'bold'), fg='black')
37enterWordLabel.place(x=180, y=20)
38
39enterWordEntry = Entry(root, font=('arial', 20, 'bold'), bd=5, justify=CENTER)
40enterWordEntry.place(x=100, y=70)
41
42enterWordEntry.focus_set()
43
44searchImage = PhotoImage(
45file='./Text_Sentimental_Analysis_Script_with_GUI/images/search.png')
46searchButton = Button(root, image=searchImage, bd=0, bg='whitesmoke', activebackground='whitesmoke', cursor='hand2',
47command=search)
48searchButton.place(x=450, y=50)
49
50root.mainloop()
51