-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
  • 112,593
  • 23
  • 157
  • 280
bartolomo
  • 15
  • 1
  • 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
  • 19,113
  • 6
  • 51
  • 82