-1
  frame=Frame(root)
  frame.place(x=55,y=50)
  L1=Label(frame,text="1",font=("calibri")).pack()
  frame1=Frame(root)
  frame1.place(x=70,y=50)
  E1 = tk.Entry(frame1, width=30, bd=4).pack()
  E1.bind('<Return>', lambda event, arg=(0): answer(event, arg))

I put an entry widget on a frame but the binding on it does not work. It says:

E1.bind('', lambda event, arg=(0): answer(event, arg)) AttributeError: 'NoneType' object has no attribute 'bind'

Sirius
  • 27
  • 1
  • 12

1 Answers1

0

tk.Entry(frame1, width=30, bd=4).pack() returns None so E1 is of NoneType, hence the error. If you do

E1 = tk.Entry(frame1, width=30, bd=4)
E1.pack()
E1.bind('<Return>', lambda event, arg=(0): answer(event, arg))

the binding should work.

j_4321
  • 15,431
  • 3
  • 34
  • 61