-2

Here is part of my code:

import tkinter

class Program:
    def __init__(self):
        self.canvas = tkinter.Canvas(1000, 500, bg="yellow")
        self.canvas.pack()

Which command should I use in order to close tkinter window (canvas)?

martineau
  • 119,623
  • 25
  • 170
  • 301
bartolomo
  • 15
  • 2
  • 7

1 Answers1

2

Just use:

self.canvas.destroy()

Or if you actually want to close the whole window and not just remove the Canvas:

self.root.destroy()
ruohola
  • 21,987
  • 6
  • 62
  • 97