-2

I'm trying to delete all text by using a button.

Here is my code:

import tkinter
from tkinter import *
from tkinter import ttk
root = Tk()

def Play():
    global label
    root.after(1000, label.destroy())

label = Label(root, text = "Welcome to ______, Click Play below if you would Like to play! ").grid(row = 15, column = 15, pady = 10, padx = 750)
button = Button(root, text = "PLAY", command = Play).grid(row = 20, column = 15, pady= 100, padx = 100, ipadx=100)
root.mainloop()
mkrieger1
  • 19,194
  • 5
  • 54
  • 65
No Edits
  • 1
  • 1

1 Answers1

0

It seems you expected label to be the result of Label(...).

But you wrote

label = Label(...).grid(...)

so label is actually the return value of grid(...), which apparently is None.

You should call grid and assign to label in two separate statements:

label = Label(...)
label.grid(...)

The same applies to button.

mkrieger1
  • 19,194
  • 5
  • 54
  • 65