【发布时间】:2019-01-08 16:03:44
【问题描述】:
所以我在 Python 中有这个来检测输入输入时的意图。
for text in texts:
text_input = dialogflow.types.TextInput(text=text, language_code=language_code)
query_input = dialogflow.types.QueryInput(text=text_input)
response = session_client.detect_intent(session=session, query_input=query_input)
print ('Chatbot: {}\n'.format(response.query_result.fulfillment_text))
detect_intent_texts("chat-8","abc",["Hey"],"en-us")
还有我现在的用户界面
myText = StringVar()
window.resizable(False, False)
window.title("Chatbot")
window.geometry('400x400')
User_Input = Entry(window, textvariable=myText, width=50).place(x=20, y=350)
subButton = Button(window, text="Send").place(x =350, y=350)
window.mainloop()
我的目标是创建一个接受用户输入的 GUI,并在提交代码时检测用户输入的内容。从上面可以看出,在最后一行 ["Hey"] 上,我可以在这里输入我喜欢的任何内容,并且聊天机器人会在控制台中做出响应,尽管它的工作原理并不是我想要实现的。
我将如何改为命令 [""] 来检测用户在 Entry 小部件中写入的内容?
【问题讨论】:
-
detect_intent_texts("chat-8","abc",[myText.get()],"en-us") -
@rioV8 我现在试试,谢谢,我想按钮也需要一个函数命令来提交文本,比如
def Response(): result = User_Input.get() -
好的@rioV8,这似乎工作,会发生什么是GUI弹出,我输入我想要的,例如你好,然后什么都没有发生......当我关闭GUI并等待1 秒响应显示在控制台中。大概是因为
print存在吧?任何想法如何在 GUI 中显示输入和输出?可能有各种标签。 -
代码太多,无法在评论中输入,请参阅答案。
标签: python tkinter dialogflow-es