1

I have used scrolledText widget for user input in my chatbot. I bind the "ENTER" key to post user response to chat window, but it's not coming to new line in user input window. Below are my code:

self.usr_input = ScrolledText.ScrolledText(self, height=3, bd=1)
self.usr_input.grid(row=10, column=0)
self.usr_input.focus()  # Sets focus to the input bar at start
self.usr_input.bind('<Return>', lambda e: self.get_response()) # Binds ENTER Key

My expectation : "ENTER KEY" --> Post to chat window ( Working)

"SHIFT + ENTER Key " --> Next line in scrolledText ( Not Working )

Please suggest if any modification is required to the above code.

Thank you in advance!

1 Answers1

0

Enter key's name: KP_Enter Shift key's name: Shift_L

Code for binding:

root.bind_all('<KP_Enter>', function1)
root.bind_all('<KP_Enter-Shift_L>', function2)

Now, all you need is to figure out what you want exactly and create function1 and function2 for doing what you need

TheOne
  • 330
  • 7
  • 25