0

i am trying to create dynamic variables to name 9 entry widgets(score_1, score_2 ...) and i want to print the number that is inserted in the entry and i am not trying to use class or other ways. And i am keep getting this error.. Please let me know what is wrong with my code. It would be great if you could correct my code. thank you for reading.

AttributeError: 'NoneType' object has no attribute 'get'
from tkinter import *

window = Tk()
window.title=("Score")
window.geometry('1200x90')

def total():
    print(score_1.get())

#create entry
    
for i in range(9):
    globals()['score_{}'.format(i)] = Entry(window,width=10).grid(row=1, column=1+i)

#button
    
b1=Button(window,text="total",command=total,fg="red",width=5)
b1.grid(row=0,column=20,sticky="ew")

window.mainloop()
AnaniasOD
  • 3
  • 2
  • No, don't use `globals` for that, seems like an abuse of the feature. Add the entries to a list or dictionary. The issue, however, is this: [Tkinter: AttributeError: NoneType object has no attribute ](https://stackoverflow.com/questions/1101750/tkinter-attributeerror-nonetype-object-has-no-attribute-attribute-name) – Matiiss Nov 25 '21 at 17:36
  • I'm sorry but would it be possible to show me the code using list? Sorry for bothering you. – AnaniasOD Nov 25 '21 at 17:39
  • Oh and thank you for the link of the error. I got that solved. – AnaniasOD Nov 25 '21 at 17:44

0 Answers0