Text implements a powerful multiline text editor, which can display images and embedded widgets as well as text in one or more fonts and colors. An instance
Text supports many ways to refer to specific points in
t supplies methods and configuration options, which allows fine-grained control of operations, content, and rendering. This section covers a large, frequently used subset of this vast functionality. In some very simple cases, you can get by with just three
t.delete('1.0', END) # clear the widget's contents t.insert(END, astring) # append astring to the widget's contents somestring = t.get('1.0', END) # get the widget's contents as a string
END is an index on any
t, indicating the end of
'1.0' is also an index, indicating the start of
t’s text (first line, first column). For more about indices, see Indices.
ScrolledText module of Python’s standard library supplies a class named
ScrolledText. To construct a
ScrolledText instance, call
ScrolledText.ScrolledText in exactly the same way you would call
s is exactly the same as a
Text instance, except that
s automatically provides a scrollbar for the
Text instance it wraps.