-2

I've got in a bit of trouble while working with tkinter The problem is that there are no methods which can work with widget Text. Here is my code

from tkinter import *
root = Tk()
tex = Text(root, width = 50, height = 10, bd = 2).pack()
tex.get(1.0, END)
root.mainloop()

It returns error:

AttributeError: 'NoneType' object has no attribute 'get'

it makes me mad! and I have such problems with any Text's methods

gofr1
  • 15,741
  • 11
  • 42
  • 52
mark
  • 1
  • 1
  • 4
  • A duplicate exists with all of the words in this question's title. Please search stackoverflow for answers before posting new questions. – Bryan Oakley May 23 '16 at 13:45

1 Answers1

4

You save the return value of "pack" in "tex", which is None. This is correct:

tex = Text(root, width = 50, height = 10, bd = 2)
tex.pack()
Matthias Schreiber
  • 2,347
  • 1
  • 13
  • 20