Reputation: 363
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()
Upvotes: 0
Views: 568
Reputation: 122024
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 pack
ed or place
d everything, rather than trying to mix and match.
Upvotes: 3