1,105,334 Community Members

Tkinter Canvas widget - text overlap problem

Member Avatar
awn
Newbie Poster
6 posts since Oct 2009
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Hi,
I'm writing an application in python to read data from a joystick and display it onto a screen with a background image overlay. i used the canvas widget to display the data to my screen.

The problem is, the text keeps updating the entries without clearing the previous entry and hence overwrites on the existing text.
Can anyone please tell me how to continuously refresh text without overwriting text enitries in the TKinter canvas widget?

cv.create_text(450, 200, text='', fill="Green", anchor='nw')
    #cv.refresh() ?
    time.sleep(0.5)
Member Avatar
masterofpuppets
Posting Whiz in Training
272 posts since Jul 2009
Reputation Points: 5 [?]
Q&As Helped to Solve: 74 [?]
Skill Endorsements: 0 [?]
 
2
 

hi,
in order to clear the previous text you can use:

t = cv.create_text( .................. )
# do stuff
time.sleep( 1 )
cv.delete( t )
cv.update()

.delete(..) deletes the widget from the canvas
.update() updates the canvas

hope this helps :)

Member Avatar
awn
Newbie Poster
6 posts since Oct 2009
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Hi,

Thank you very much for your reply with that information and the syntax. Greatly appreciate it. Yes - It worked perfectly.

Question Answered as of 4 Years Ago by masterofpuppets
You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article