Canvas Update Tkinter Python
<p>I wrote a method to create a canvas</p>

<p>But I see that Canvas is not updated and the Gui elements are not updated</p>

<p>Please guide here as i want to implement the New Game functionality</p>

<p>Removing all references to a Tkinter widget (like a <code>Canvas</code>) doesn't necessarily delete that object (or its child widgets) from a Tkinter application. You can test this with a small script:</p>

<pre><code>import tkinter as tk
root = tk.Tk()
def f():
    tk.Label(root, text='hi').pack()

f()
</code></pre>

<p>No reference to that <code>Label</code> is ever saved, and it's local to a function scope anyway, and yet it persists. If you want to get rid of a Tkinter widget, use its <code>destroy</code> method.</p>

<pre><code>self.canvas.destroy()
self.canvas = tk.Canvas(self, width=2000, height=800)
...
</code></pre>

<p>Note that it's still good practice to keep references to your Tkinter objects so that you can work with them (like calling <code>destroy()</code> on them, for example), and some Tkinter objects actually are discarded when there are no more references to them, like image objects (e.g. as used by <a href="http://effbot.org/tkinterbook/canvas.htm#Tkinter.Canvas.create_image-method" rel="nofollow"><code>Canvas.create_image</code></a> and <a href="http://effbot.org/tkinterbook/label.htm#patterns" rel="nofollow"><code>Label</code></a>).</p>

python tkinter