[Tutor] tkinter event question

Glen Wheeler wheelege@hotmail.com
Fri, 22 Feb 2002 23:24:34 +1100

  Hi guys,

  I've come to a little problem with tkinter events.  What I want to do, is
catch an event and stop the default action from going through while still
letting my action happen.
  Case in point - I have a one line text field, and when the user presses
<return> I want a specific function to be called.  That all works fine - but
after the function has returned from it's business, a '\n' is added to the
end of the text field making it two lines.
  I think I can force the text field to only one line, but I'd rather just
stop the default action (add a \n to the text) from happening.  I did a few
experiments, and found out that the \n was being placed after my function
had executed.  A nice side-effect of this is that I can't just go text =
text[:-1] to chop off the \n - it's added after my function returns!
  Alright, I just figured out how to solve it...  make it an entry widget
instead of a text one.  Can't believe I didn't think of that.  But, still,
I'd liek to ask the question - how to emulate the no-newline-char-generated
effect of the entry eidget?  Does it need to be hardcoded deep into tk?