-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGUI.py
More file actions
88 lines (67 loc) · 2.42 KB
/
GUI.py
File metadata and controls
88 lines (67 loc) · 2.42 KB
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
from tkinter import *
from PIL import Image, ImageTk
import action
import speech_to_text
root = Tk()
root.title("Virtual Assistant")
root.geometry("550x675")
root.resizable(False,False)
root.config(bg="#171616")
# functions
def ask():
user_val = speech_to_text.speech_to_text()
bot_val = action.Action(user_val)
text.insert(END, 'User--->'+ user_val+"\n")
if bot_val != None:
text.insert(END, "BOT <---"+ str(bot_val)+"\n")
if bot_val == "Okey sir":
root.destroy()
def send():
send = entry.get()
bot = action.Action(send)
text.insert(END, 'User--->'+ send+"\n")
if bot != None:
text.insert(END, "BOT <---"+ str(bot)+"\n")
if bot == "Okey sir":
root.destroy()
def del_text():
text.delete('1.0', "end")
def on_entry_click(event):
if entry.get() == "Promt here":
entry.delete(0, "end")
entry.insert(0, "")
def on_focusout(event):
if entry.get() == "":
entry.insert(0, "Promt here")
#frame
frame = LabelFrame(root, padx=100, pady = 7, borderwidth=3, relief="raised")
frame.config(bg="#EAE7E7")
frame.grid(row = 0, column = 1, padx = 55, pady = 10)
#text label
text_label = Label (frame, text="Virtual Assistant", font=("Kanit", 14, "bold"), bg="#356696")
text_label.grid(row = 0, column = 0, padx = 20, pady = 10 )
#icon
image_icon=PhotoImage(file="image/chat-icon-transparent-3-removebg-preview.png")
root.iconphoto(False,image_icon)
#image
image = ImageTk.PhotoImage(Image.open("image/4416482-removebg-preview.png"))
image_label = Label(frame, image=image)
image_label.grid(row = 1, column = 0, pady = 20)
#input a text_area
text = Text(root, font=("courier", 10, "bold"), bg="#356696")
text.grid(row = 2, column = 0)
text.place(x = 100, y = 375, width = 375, height = 100)
#enrty text_area
entry = Entry(root, justify=CENTER, fg="#2D2D2D")
entry.insert(0, "Promt here")
entry.bind('<FocusIn>', on_entry_click)
entry.bind('<FocusOut>', on_focusout)
entry.place(x=100, y=500, width=375, height=30)
#buttons
Button1 = Button(root, text="Ask" , bg="#356696", pady=16, padx=40, borderwidth=3, relief=SOLID , command=ask)
Button1.place(x=70, y=575)
Button2 = Button(root, text="Send" , bg="#356696", pady=16, padx=40, borderwidth=3, relief=SOLID , command=send)
Button2.place(x=400, y=575)
Button3 = Button(root, text="Delete" , bg="#356696", pady=16, padx=40, borderwidth=3, relief=SOLID , command=del_text)
Button3.place(x=230, y=575)
root.mainloop()