The Text Widget

Ali K akakakhel at attbi.com
Sat Mar 9 18:53:43 EST 2002


I want to know how to write inside a text widget from inside my program.
The following code didn't work.

def enterPress:
    comm = input.get()
    history.insert(INSERT, comm)

here input is the entry widget from which i am gathering my data and history
is the text widget i am trying to write to.  This code adds some text into
the textbox, but not on a new line.  How do i get it to do that?

"Eric Brunel" <eric.brunel at pragmadev.com> wrote in message
news:a5vcb6$2vbb$1 at norfair.nerim.net...
> Edward K. Ream wrote:
> > First, note that if you bind to a key-press (<Key>) event, when the
> > event handler is called the Text widget hasn't been changed yet(!)
> > Other frameworks provide a "text will change" event and a "text did
> > change" event, but AFAIK Tk does not.
>
> Tk does: it's simply that the event "<Key>" is a short-cut for
> "<KeyPress>", called when the key is depressed, so before the insertion
> happened. To do a binding after the text has been inserted, the event is
> "<KeyRelease>".
>
> For Ali's problem, I don't exactly understand what you want to do. When
> reading your mail, it seems to me that a sub-class of Tkinter.Text with a
> redefined "insert" method may do the trick. Or is it more complicated?
>
> HTH
>  - eric -





More information about the Python-list mailing list