-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
56 lines (45 loc) · 1.46 KB
/
app.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
import eel
import os
from queue import Queue
class ChatBot:
started = False
userinputQueue = Queue()
def isUserInput():
return not ChatBot.userinputQueue.empty()
def popUserInput():
return ChatBot.userinputQueue.get()
def close_callback(route, websockets):
# if not websockets:
# print('Bye!')
exit()
@eel.expose
def getUserInput(msg):
ChatBot.userinputQueue.put(msg)
print(msg)
def close():
ChatBot.started = False
def addUserMsg(msg):
eel.addUserMsg(msg)
def addAppMsg(msg):
eel.addAppMsg(msg)
def start():
path = os.path.dirname(os.path.abspath(__file__))
eel.init(path + r'\web', allowed_extensions=['.js', '.html'])
try:
eel.start('index.html', mode='chrome',
host='localhost',
port=27005,
block=False,
size=(350, 480),
position=(10,100),
disable_cache=True,
close_callback=ChatBot.close_callback)
ChatBot.started = True
while ChatBot.started:
try:
eel.sleep(10.0)
except:
#main thread exited
break
except:
pass