Python Forum
[Tkinter] How to erase previous output from the canvas?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] How to erase previous output from the canvas?
#5
Found two solutions in the end, just in case anyone is interested:

1. When an object is created, it's ID is returned, save that:

Quote:the_id = canvas1.create_window(200, 250, window=label4)

then:
Quote:canvas1.delete(the_id)

If you use this in a callback to a function, you need to declare it global:
Quote:global the_id
2. Use a tag:

Quote:canvas1.create_window(200, 250, window=label4, tags="label")

then:
Quote:canvas1.delete("label")

More than 1 object may have the same label, so that allows you to do things to all objects with that tag.
Reply


Messages In This Thread
RE: How to erase previous output from the canvas? - by Pedroski55 - Jul-05-2020, 10:25 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [Tkinter] Resizing image inside Canvas (with Canvas' resize) Gupi 2 25,208 Jun-04-2019, 05:05 AM
Last Post: Gupi
  [Tkinter] output to canvas widget freakbot 2 9,993 Dec-01-2016, 12:24 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020