I am writing a function that takes a textbox object from the tkinter library as an argument. When I fill in the textbox and hit the button, I get
"AttributeError: 'NoneType' object has no attribute 'get'."
I know for a fact the textbox object has get() as a function. I even imported the tkinter library into the file that has my function. Here's a simplified version of what I am trying to do in two files:
main:
import tkinter
import save_file
app = tkinter.Tk()
textbox = tkinter.Text(app).pack()
button = tkinter.Button(app, command=lambda: save_file.save_file(textbox))
save_file:
import tkinter
def save_file(textbox):
text = textbox.get()
Can anyone tell me what I am doing wrong?
pack()
returns None
; you want to store just the Text()
object, then call pack()
on it separately:
textbox = texinter.Text(app)
textbox.pack()