I am making a simple GUI program in python using Tkinter. The problem is that when I try to retrieve the value from my Entry using a button, it comes back with an error()
:
print(ex1.get())
AttributeError: 'NoneType' object has no attribute 'get'
How to avoid this?
This is my code:
root = Tk()
root.minsize(300,300)
root.maxsize(300,300)
n = ttk.Notebook()
f1 = Frame(n,height=280,width=280)
f1.propagate(0)
lx1 = Label(f1,text="x",width=5).grid(row = 1,column=0)
ex1 = Entry(f1,width = 10).grid(row = 1,column = 1)
ly1 = Label(f1,text="y",width=5).grid(row=3,column=0)
ey1 = Entry(f1,width = 10).grid(row=3,column = 1)
def value():
print(ex1.get())
Bcreate = Button(f1,text="CREATE",command=value).grid(row = 10,column = 5)
n.add(f1,text="add point")
f2 = Frame(n)
n.add(f2,text="draw line")
n.pack()