Q on Tkinter Scrollbar
Baetz; Bradley Michael
bbaetz at ug.cs.su.oz.au
Thu Apr 29 22:19:09 EDT 1999
you can use the "@x,y" index syntax for this; the
start of the visible text is "@0,0", the end is "@x,y"
where x and y is the window size (or anything
larger, like "@10000,10000").
also see the attached example.
....
def report_position():
# get (beginning of) first visible line
top = text.index("@0,0")
# get (end of) last visible line
bottom = text.index("@0,%d" % text.winfo_height())
Thanks a lot for your help. The only thing I don't understand is why the above line returns the position of the _end_ of the line. I know it does (I tried it), but wouldn't the "@0,%d" mean that text.index returns the absolute index to the position where x=0 (ie the beginning of the line), not the end? Now looking at your comments :), I would have got the absolute line number, and then used lineno.end as the index. What did I miss?
Thanks a lot,
Bradley
More information about the Python-list
mailing list