0

I have made a text box and a button. When the button is clicked it should display the content within the text box.

I have followed a tutorial but I couldn't get it to work, so I then came on here and found a thread where someone else had this problem, but I still couldn't figure out why mine gives this error.

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

Here is the code.

def send_feedback(*args):
    feedback = self.MyEntryBox.get("0.0",'END-1c')
    print(feedback)

self.MyEntryBox = Text(SWH, width=80, height=20, bd=5, fg="#0094FF",relief = RIDGE).place(x=200,y=400)
SubmitButton = Button(SWH, text="Submit", fg="White", bg="#0094FF", font=("Grobold",20),command=send_feedback).pack()
Community
  • 1
  • 1
B.Hawkins
  • 353
  • 5
  • 13

1 Answers1

3

You are assigning None to SubmitButton and self.MyEntryBox, because that is what widget.pack() and widget.place() return.

Instead, make it two separate lines for each widget, so you assign the widget to an accessible name then position the widget in the UI:

self.MyEntryBox = Text(SWH, width=80, height=20, bd=5, fg="#0094FF", relief = RIDGE)
self.MyEntryBox.place(x=200, y=400)
SubmitButton = Button(SWH, text="Submit", fg="White", bg="#0094FF", 
                      font=("Grobold", 20), command=send_feedback)
SubmitButton.pack()

Also, SubmitButton should probably be an instance attribute like MyEntryBox, and it would probably be easier if you packed or placed everything, rather than trying to mix and match.

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
  • Great Stuff! Thanks very much. Concerning the .pack() and .place() I am using .place throughout my program just while i was getting this page working i just packed the button for simplicity. Thanks again. – B.Hawkins Sep 08 '14 at 09:57