Skip to content

Commit 99cdd2a

Browse files
authored
Add files via upload
1 parent 012d48f commit 99cdd2a

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

script/order_bot_program/order_bot.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from time import sleep
1414

1515
# setting
16-
from setting import menu_xlsx_path
16+
from setting import menu_xlsx_path, command_data_dict
1717

1818
# order process modules
1919
# process order
@@ -49,6 +49,12 @@ def line_speaker(self, texts,lang='zh-tw'):
4949
def listener(self):
5050
if self.mode == 'text':
5151
result = input()
52+
elif self.mode == 'tk_text':
53+
while(not command_data_dict['is_command']):
54+
pass
55+
command_data_dict['is_command'] = False
56+
result = command_data_dict['command_line']
57+
print(result)
5258
elif self.mode == 'voice1':
5359
result = None
5460
while(result == None):
@@ -120,6 +126,7 @@ def order_manage(self):
120126
data_dict = load_xlsx(file_name=menu_xlsx_path)
121127
menu_dict = process_data_to_menu(data_dict)
122128
self.line_speaker('您好,很高興為您服務,請問要做些甚麼?')
129+
order_line = self.listener()
123130

124131
# 問好
125132
if '你好' in order_line:
@@ -198,4 +205,4 @@ def __call__(self):
198205
if __name__ == '__main__':
199206
order_bot = Order_Bot('text')
200207
order_bot.mode = 'voice2'
201-
order_bot()
208+
order_bot()

script/order_bot_program/order_program.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
# order bot
88
from order_bot import Order_Bot
99

10+
from setting import command_data_dict
11+
1012
class Gui_helper_main:
1113
def __init__(self):
1214
self.root = Tk()
@@ -30,6 +32,10 @@ def switch_frame(self, index):
3032
self.frame.grid(column=0, row=0, sticky=N+W)
3133

3234
def run(self):
35+
from threading import Thread
36+
thread1 = Thread(target=self.frames[0].order_bot)
37+
thread1.setDaemon(True)
38+
thread1.start()
3339
self.root.mainloop()
3440

3541
def quit(self):
@@ -43,7 +49,7 @@ def __init__(self, master):
4349
self.master = master.root
4450

4551
# order bot
46-
self.order_bot = Order_Bot('text')
52+
self.order_bot = Order_Bot('tk_text')
4753

4854
# display last order
4955
self.last_order = StringVar()
@@ -64,6 +70,8 @@ def update_string_var(self):
6470

6571
def order(self):
6672
order_command = self.order_enter_box.get()
73+
command_data_dict['command_line']=order_command
74+
command_data_dict['is_command']=True
6775

6876
if __name__ == '__main__':
6977
main = Gui_helper_main()

0 commit comments

Comments
 (0)