I am trying to make Tkinter Canvas text of length x continuously scroll across a finite area less than x. I have multiple canvastext objects with different text. If I print(newtext) it shows the scroll i want but it does not display during the running of the program. I tried with a while True: loop and it never displayed the canvas at all. Any help would be appreciated.
text='really long text string that i want to scroll 15 characters at a time'
canvastext=canvas.create_text(1,1,text=scrolltext(text),
tag=(calmotag,booktag,'texttag'),width=20)
def scrolltext(text):
textlength=15
shorttext=tkinter.StringVar()
shorttext.set(text.get()[0:14])
itemtext=text.get()
if len(itemtext)>textlength:
newindex=0
endindex=newindex+14
while endindex<len(itemtext)+2:
oldtext=shorttext.get()
oldindex=itemtext.index(oldtext)
newindex=oldindex+1
endindex=newindex+14
newtext=itemtext[newindex:endindex]
shorttext.set(newtext)
root.update_idletasks()
root.after(1000)