Is there a more efficient way to get the total number of display lines (not just visible ones) that are left in a tkinter
Text
widget after the text insert than with this makeshift function I came up with (in Python 3.4.2):
def get_display_lines():
#Gets the total number of display lines after the text insert in the current tab (not just those on-screen, though).
myTextWidget.mark_set("dlines", INSERT)
count=0
while 1:
if myTextWidget.compare("dlines", ">=", "end-1c linestart"):
break
else:
myTextWidget.mark_set("dlines", "dlines + 1 display line")
count+=1
return count
Anyway, this code works, but it's rather inefficient. I'm using it to calculate the time left to autoscroll through the remainder document. The inefficiency causes problems when moving the text insert with the arrow keys (which calls this function so as to show a current accurate time). It makes moving the insert much slower, and slower to update, and can even crash/freeze it.
I know there are much more efficient ways to get the total number of lines in a Text widget. However, I need the display lines, because reading with autoscroll is usually done with the wordwrap on.
My autoscroll feature goes down from the insert a user-chosen number of lines every so many seconds (which number of second is also chosen by the user). It's not done through the scrollbars.