I am learning python right now, and I'm working on making graphics. It was working for a while, making a window and displaying the correct graphics, but somehow I messed up the formatting and now it always shows an error when I run the program.
I have already tried removing the formatting and letting VS Code auto-format it for me, but it still shows the same error.
Here is first.py
:
from graphics import *
import time
def isset(v):
return v in locals() or v in globals()
a = GraphWin('Test', 1000, 800)
a.setCoords(1000, -800, -1000, 800)
a.setBackground('white')
b = Entry(Point(0, 0), 20)
b.setFill('white')
b.draw(a);
c = Text(Point(0, 80), 'What is your name?')
c.draw(a)
while True:
key = a.checkKey()
if key == 'Return':
if b.getText():
d = Text(Point(0, 0), 'Hello, '+str(b.getText())+'!')
b.setText('')
b.undraw()
c.undraw()
d.draw(a)
time.sleep(2)
d.undraw()
b.draw(a)
c = Text(Point(0, 80), 'How old are you?')
c.draw(a)
break
while True:
key = a.checkKey()
if key == 'Return':
if b.getText():
d = Text(Point(0, 0), 'You are '+str(b.getText())+' years old!')
b.undraw()
c.undraw()
d.draw(a)
time.sleep(1)
for i in range(5, 0, -1):
if isset('e'):
e.undraw()
e = Text(Point(0, -80), 'Window closing in: '+str(i))
e.draw(a)
time.sleep(1)
break
Here is the terminal output:
$ python3 first.py
File "first.py", line 17
d = Text(Point(0, 0), 'Hello, '+str(b.getText())+'!')
^
TabError: inconsistent use of tabs and spaces in indentation
Please tell me what I am doing wrong!
I cannot figure out for the life of me what is going on with my code and it's driving me insane.