I'm trying to get the number of displayed lines in a Tkinter Text widget and I'm looking at this question: What's the most efficient way to get a Tkinter Text widget's total display lines after the insert?
The solution I'm interested in uses the widget's count method but on my Python 2.7.10 (Tk 8.5, Tcl 8.5) the text widget does not have that attribute.
import Tkinter
root = Tkinter.Tk()
text = Tkinter.Text()
text.pack()
def test(event):
print "displaylines:", text.count("1.0", "end", "displaylines")
print "lines:", text.count("1.0", "end", "lines")
text.insert("1.0", "a" * 81)
text.insert("2.0", "b\n")
text.bind('<Map>', test)
root.mainloop()
yields
AttributeError: Text instance has no attribute 'count'
From what documentation that I've found it should be there; have I missed something?