0

I'm using a Tkinter Text box in my Python (using 2.7.2) script as an entry-type box -- when enter is pressed, it copies the contents into a different text box and then deletes it out of the entry one.

I've bound the necessary event to the Text box when the Enter key is pressed.

The only problem I have is that whenever I hit the Enter key, it seems to execute my event and then the widgets "default" binding: adding a newline. I'm not sure of a way to either delete the newline after it is added, or simply get rid of the widgets default binding.

Thanks a lot!

  • possible duplicate of [python gui events out of order](http://stackoverflow.com/questions/2458026/python-gui-events-out-of-order) – Bryan Oakley Oct 20 '11 at 23:30

2 Answers2

0

Returning 'break' at the end of your event handler will interrupt event propagation.

Steven Rumbalski
  • 44,786
  • 9
  • 89
  • 119
0

Variations of this question have been asked before. The short answer is "do a return "break" in the code executed by your binding.

I gave a much longer answer here: python gui events out of order

Community
  • 1
  • 1
Bryan Oakley
  • 370,779
  • 53
  • 539
  • 685