0

I am writing a script that will take an input from a Tkinter GUI with 2 Entry widgets and a Text widget.

This is just part of my code:

root = Tk()
...
text = Text(root)

root.mainloop()

What I need is to get all the contents of the Text widget.

nbro
  • 15,395
  • 32
  • 113
  • 196

1 Answers1

3

To read the entire contents of a Text widget, use

text.get("1.0", "end-1c")

Note that with "end-1c" you get exactly what the user typed without the trailing newline automatically added by the widget.

nbro
  • 15,395
  • 32
  • 113
  • 196
TidB
  • 1,749
  • 1
  • 12
  • 14
  • Just an addition, for all widgets where you type, the ```.get()``` method exists. For all of them, such as Entry, and Text, and dropdrown menu as well. –  Apr 04 '19 at 19:49