f



How to capture text in tk widget

Hi,
   I have a tk text window. My need is - if I highlight some portion
of text with mouse, it should automatically be saved into a variable.
Please suggest me on how to do this.

Thanks,
Balajee
0
balajee4 (31)
4/28/2010 11:13:28 AM
comp.lang.tcl 23429 articles. 2 followers. Post Follow

1 Replies
691 Views

Similar Articles

[PageSpeed] 30

On 28 apr, 13:13, balajee <balaj...@gmail.com> wrote:
> Hi,
> =A0 =A0I have a tk text window. My need is - if I highlight some portion
> of text with mouse, it should automatically be saved into a variable.
> Please suggest me on how to do this.
>
> Thanks,
> Balajee

You need to set up a binding for the event that ends the selection,
something along these lines:

..text configure -exportSelection 1
bind .text <<Selection>> {set selectedText [.text get [.text tag range
"sel"]]}

(just a sketch, the details won't be right)

Regards,

Arjen
0
Arjen
4/28/2010 1:23:22 PM
Reply: