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?
#4
Thanks, but that is a bit of an overkill, wiped out all my other stuff!

I just want to delete label4 before I recreate it.

To do that, I think I need to get the ID of label4, which is an integer.

How can I get label4's ID?

Just guessing, I used ID = 4 for label4 the first time. That worked, the previous text was gone.

To begin with, I made label4, so that getInput() has something to delete:

label4 = tkinter.Label(frame, text= 'Your input will be here after you click the button.',font=('helvetica', 10, 'bold'), anchor='w', wraplength=390)
    canvas1.create_window(200, 250, window=label4)    
I put

canvas1.delete(4)
in getInput() at the beginning. Sure enough, the text I put there in the beginning was gone.

But, the next time that ID did not work, because label4 was deleted. The new label4 probably has an ID that went up by 1.

How can I get the integer ID of label4 each time around?
Reply


Messages In This Thread
RE: How to erase previous output from the canvas? - by Pedroski55 - Jul-04-2020, 09:15 AM

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