-1
entry = tkinter.Entry(root, width=40, borderwidth=5).grid(row =0, columnspan=4, padx=10, pady=20)

def Number_click(number):
    Current = str(entry.get())
    entry.insert(0, Current+str(number))

Says

AttributeError: 'NoneType' object has no attribute 'insert' number is a lambda var.....

Please help.

acw1668
  • 40,144
  • 5
  • 22
  • 34

1 Answers1

1
entry = tkinter.Entry(root, width=40, borderwidth=5)
entry.grid(row =0, columnspan=4, padx=10, pady=20)

It must be on 2 lines

Nikolay Patarov
  • 305
  • 3
  • 11
  • 1
    Can you please give an explanation as to why it should be on 2 lines? Something like: `.grid` returns `None` so `None` is stored in `entry` and not the `tkinter.Entry` object – TheLizzard May 18 '21 at 09:26
  • also no, it is not necessary for it to be on two lines so that _must_ is out of place, it is still possible to add the `Entry` in one line `Entry(master, textvariable=var, **options).grid(**options)` but as You may have noticed there is a `texvariable` which meanst that in the line before You sould write `var = StringVar()` for this to work, and then it is possible to use `var.get()` for the same effect. So Entry can be written in one line and still be used, not that You should, but it is not a _must_ – Matiiss May 18 '21 at 10:05
  • For Python 3.8+, can use `(entry := Entry(...)).grid(...)`. – acw1668 May 18 '21 at 11:35