Whoa!  You guys are pretty smart.  This seems to give the "line" number of the 
first visible.  If text is wrapped in the Text() into a paragraph (multiple 
lines) the actual beginning of the "line" may be out of view, but that's no 
problem.  I missed the "@0,__" thing.  Works great!

Thanks!

On 2013-02-27, at 16:33, Michael Lange <klappn...@web.de> wrote:

> Hi,
> 
> On Wed, 27 Feb 2013 14:35:11 -0800
> Lion Kimbro <lionkim...@gmail.com> wrote:
> 
>> Perhaps use window coordinates?
>> 
>> There's a way of indexing with "@x,y" that might work.
>> 
>> http://infohost.nmt.edu/tcc/help/pubs/tkinter/web/text-index.html
>> https://www.tcl.tk/man/tcl8.4/TkCmd/text.htm#M20
> 
> yes, something like this might do the trick:
> 
> from Tkinter import *
> from ScrolledText import ScrolledText
> 
> root = Tk()
> text = ScrolledText(root)
> text.pack(side='left', fill='both', expand=1)
> f = open('/etc/fstab', 'r')
> text.insert('end',f.read())
> f.close()
> 
> def test(ev):
>  y0, y1 = text.yview()
>  print text.index('@0,%d' % y0)
> 
> root.bind('<F1>', test)
> root.mainloop()
> 
> Regards
> 
> Michael
> 
> 
> .-.. .. ...- .   .-.. --- -. --.   .- -. -..   .--. .-. --- ... .--. . .-.
> 
> Even historians fail to learn from history -- they repeat the same
> mistakes.
>               -- John Gill, "Patterns of Force", stardate 2534.7
> _______________________________________________
> Tkinter-discuss mailing list
> Tkinter-discuss@python.org
> http://mail.python.org/mailman/listinfo/tkinter-discuss
> 

_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss@python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss

Reply via email to