【发布时间】:2024-04-17 21:25:02
【问题描述】:
def radio():
def sel():
selection = "You selected the option " + str(var.get())
label.config(text = selection)
var = IntVar()
R1 = Radiobutton(base, text="Option 1", variable=var, value=1,
command=sel)
R1.pack( anchor = W )
R2 = Radiobutton(base, text="Option 2", variable=var, value=2,
command=sel)
R2.pack( anchor = W )
R3 = Radiobutton(base, text="Option 3", variable=var, value=3,
command=sel)
R3.pack( anchor = W)
label = Label(base)
label.pack()
ChatLog.config(state=NORMAL)
ChatLog.insert(END, "Bot: " + R1 + '\n\n')
ChatLog.yview(END)`enter code here`
base = Tk()
base.title("POS Chatbot")
base.geometry("400x500")
base.resizable(width=FALSE, height=FALSE)
#Create Chat window
ChatLog = Text(base, bd=0, bg="white", height="8", width="50", font="Arial",)
ChatLog.config(state=DISABLED)
ChatLog.config(foreground="#442265", font=("Verdana", 12 ))
#Bind scrollbar to Chat window
scrollbar = Scrollbar(base, command=ChatLog.yview, cursor="heart")
ChatLog['yscrollcommand'] = scrollbar.set
#Create Button to send message
base.bind('<Return>',call )
SendButton = Button(base, font=("Verdana",12,'bold'), text="Send", width="12", height=5,
bd=0, bg="#32de97", activebackground="#3c9d9b",fg='#ffffff',
command= send )
#Create the box to enter message
EntryBox = Text(base, bd=0, bg="white",width="29", height="5", font="Arial") #Place all components on the screen
scrollbar.place(x=376,y=6, height=386)
ChatLog.place(x=6,y=6, height=386, width=370)
EntryBox.place(x=128, y=401, height=90, width=265)
SendButton.place(x=6, y=401, height=90)
base.mainloop()
单选按钮出现在主窗口中,但不是响应。请帮我弄清楚在聊天机器人中添加按钮类型响应需要做什么。下面是我用于此机器人的 JSON 文件数据集。按钮类型响应的数据集中是否有任何更改。请指导我解决这个问题
{
"intents": [{
"tag": "greeting",
"patterns": ["Hi", "How are you", "Is anyone there?", "Hello", "Good day"],
"responses": ["Hello, thanks for visiting", "Good to see you again", "Hi there, how can I help?"],
"context_set": ""
},
{
"tag": "thanks",
"patterns": ["Thanks", "Thank you", "That's helpful"],
"responses": ["Happy to help!", "Any time!", "My pleasure"]
},
{
"tag": "bye",
"patterns": ["bye", "good bye", "bubuye"],
"responses": ["Have a nice day!", "Bye! I helped you", "Bye! Eager to see you again"]
},
{
"tag": "pinpad",
"patterns": ["I am having issue with the pinpad", "pinpad is not working", "PED is not working", "PP is not working", "issue with PED", "Card transactions are not going on", "pin pad is having issue"],
"responses": ["please enter the till mac id the pinpad is connected with"]
},
{
"tag": "scale",
"patterns": ["I am having issue with the scale", "scale is not working", "weigh scale is not working", "weigh check is not working", "issue with scale", "weigh scale is not going on"],
"responses": ["please enter the till mac id the scale is connected with"]
},
{
"tag": "tasks",
"patterns": ["What can you do?", "What are your features?", "What are you abilities", "can you sing", "can you talk"],
"responses": ["I am here to solve POS related technical issue", "Right now i'm in developing stage as soon i'm developed"]
},
{
"tag": "POS",
"patterns": ["Who are you?", "tell me about yourself", "tell me about you", "what is your name"],
"responses": ["Hi I'm POS Support and i'm an AI created for solving your technical issue", "POS AI here, a very advance chatbot", "POS AI, chatbot of future"],
"context_set": ""
},
{
"tag": "creator",
"patterns": ["Who is your creator?", "who created you", "who is your father", "who is your daddy"],
"responses": ["I was created by POS Team"],
"context_set": ""
}, {
"tag": "issue",
"patterns": ["Issue", "I have an issue", "Issue occuring frequently", "not working"],
"responses": ["Can you please say the issue is in pinpad,scale or scanner?"],
"context_set": ""
}
]
}
【问题讨论】:
标签: python tkinter radio-button chatbot