Text widget

Matthew Dixon Cowles matt at mondoinfo.com
Wed Feb 26 15:39:59 EST 2003


On Wed, 26 Feb 2003 10:27:51 +0100, Thor <thor__00 at yahoo.com> wrote:

> is tehre any function.. or any way to get the whole text tat it is
> written in a text widget in Tkinter, all at the same time and assign
> it to a variable?

Sure:

>>> from Tkinter import *
>>> r=Tk()
>>> t=Text(r)
>>> t.pack()
>>> a=t.get("1.0",END)
>>> a
'Wibble\nWibble\nFoo\n'

The method get() takes Tk-style indexes. There's more information
about just how they (and the rest of Tkinter) work in Fredrik Lundh's
excellent An Introduction to Tkinter. It's at:

http://www.pythonware.com/library/tkinter/introduction/index.htm

Regards,
Matt




More information about the Python-list mailing list