I have begon making a game with python but i can't get the widget.destroy() to work. It says it is undefined. Here is the log:
Exception in Tkinter callback
Traceback (most recent call last):
File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/tkinter/__init__.py", line 1892, in __call__
return self.func(*args)
File "/data/user/0/ru.iiec.pydroid3/files/temp_iiec_codefile.py", line 12, in start
title.destroy()
NameError: name 'title' is not defined
from tkinter import Tk, Canvas, Label, Button
class Game():
def __init__(self):
self.startscreen()
def startscreen(self):
title = Label(root, bg='dark red', text='story game', font=('Arial', 25)).place(x = 150, y = 100)
startbutton = Button(root, text='start', bg='dark orange', font=('Arial', 15), command=self.start).place(x = 400, y = 1000)
def start(self):
title.destroy()
cw = 1100
ch = 2200
root = Tk()
c = Canvas(root, bg='dark red', width=cw, height=ch)
c.pack()
Game()
root.mainloop()