3
I’m trying to come up with a Tkinter show to count backwards.
I can’t understand why I can’t take Entry and turn it into an integer. (As this is just a test, I did using Portuguese same)
from tkinter import*
root = Tk()
inicio = Entry(root)
#adicionei esta linha abaixo
print(inicio.get())
sec = int(inicio.get())
def tick():
global sec
if sec == 0:
time['text'] = 'TEMPO ESGOTADO'
else:
sec = sec - 1
time['text'] = sec
time.after(1000, tick)
label = Label(root, text="Quanto tempo você tem para realizar suas tarefas?")
label.grid(row=0, column=0)
inicio.grid(row=1, column=0)
time = Label(root, fg='green')
time.grid(row=2, column=0)
Button(root, fg='blue', text='Start', command=tick).grid(row=3, column=0)
root.mainloop()
Only one blank space has been printed, as you can see.
Young man, what is the problem that occurs?
– Jéf Bueno
line 6, in <module> sec = int(start.get()) Valueerror: invalid literal for int() with base 10: ' '
– F Navy
Has how you print the value you are trying to convert and post it here?
– Jéf Bueno
I’m not trying to convert anything yet, the program doesn’t open... it’s just in the terminal
– F Navy
Orra, young man. That
sec = int(inicio.get())
is an attempt at conversion. Doprint(inicio.get())
and post what is shown on the screen.– Jéf Bueno
pardon for ignoring... I am beginner. I added the line and the terminal continues giving the same message
– F Navy
Obviously it continues with the same error message,
print
only serves to display a certain value in the default output. What was the value shown?– Jéf Bueno
Okay, your question is answered. "Space" is not a valid number, as it would be possible to convert a space to a number?
– Jéf Bueno