Pmw.ScrolledText: selecting a line?

Matthew Dixon Cowles matt at mondoinfo.com
Sun Dec 30 13:47:03 EST 2001


On Thu, 20 Dec 2001 12:27:52 -0700, Bob Greschke <bob at passcal.nmt.edu>
wrote:

>I can click on a point on the graph and get the ScrolledText field to
>jump to the corresponding line in the file with .yview(line number),
>but how (if possible) can I get the line to then also be 'selected'
>or 'highlighted' somehow so the user knows which line the point is
>associated with?

Dear Bob,
You can tag the appropriate line and configure the tag to highlight
the text. Here's a small example:

>>> from Tkinter import *
>>> import Pmw
>>> r=Tk()
>>> t=Pmw.ScrolledText(r)
>>> t.pack()
>>> t.insert(END,"one\ntwo\nthree\nfour\nfive\nsix\nseven\n")
>>> t.component("text").tag_add("standout","2.0","2.end")
>>> t.component("text").tag_configure("standout",background="yellow")

Regards,
Matt



More information about the Python-list mailing list