Reputation: 3
I want to get the text from 3 different entry boxes to 3 variables with the click of 1 button, but it gives me an error if I try to get more than 1.
from tkinter import StringVar
from tkinter import *
root = Tk()
a = Entry(root)
b = Entry(root)
c = Entry(root)
def callback():
a_return = [a.get(),b.get(),c.get()]
b = Button(root, text="get", width=10, command=callback).pack()
mainloop()
a_return = [a.get(),b.get(),c.get()]
AttributeError: 'NoneType' object has no attribute 'get'
Upvotes: 0
Views: 73
Reputation: 385970
You are trying to use b
for more than one thing. First you set it to an entry, and then you set it to None
when you create the button (because Button(...).pack()
returns None
).
Upvotes: 3