TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'
Dung Do Tien Jun 14 2021 334
I'm begining with some code as below:
from tkinter import *
top = Tk()
def spam():
for i in range(int(a1)):
print(i)
sbmitbtn = Button(top, text = "Login",activebackground = "Black", activeforeground = "white",command=spam).place(x = 40, y = 180)
a1 = Entry(top).place(x = 90, y = 60)
But when I run code, I got an error "TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'"
How can I fix it?
Have 1 answer(s) found.
- N-2
Nguyen Quoc Viet Jun 14 2021
You should use
get()
method to get the value of the Entry:for i in range(int(a1.get())): print(i)
And replace:
a1 = Entry(top).place(x = 90, y = 60)
To
a1 = Entry(top) a1.place(x = 80, y = 50)
I hope it works for you.
* Type maximum 2000 characters.
* All comments have to wait approved before display.
* Please polite comment and respect questions and answers of others.