Any pointers or must I use a [.txt get] widget command to get the value?
Cheers,
Rob Sciuk
You must use [.txt get]. There's much more in the text widget beside
text (images, embedded windows, tags, etc) so a textvariable doesn't
make much sense as a general purpose mechanism.
That being said, I think there's code to emulate a textvariable on the
wiki. It's doable with read traces.
> Date: Wed, 20 May 2009 09:37:06 -0700 (PDT)
> From: suchenwi <richard.suchenw...@siemens.com>
> Newsgroups: comp.lang.tcl
> Subject: Re: looking for -textvariable option for text widget ...
Thanks to Richard and Bryan. I can take it from here ... I should have
scoured the wiki better than I did ... sorry.
Rob.
Something quick-and-dirty using the "<<Modified>>" event...
#START OF EXAMPLE
proc textvariable {widget variable} {
upvar $variable var
if {[$widget edit modified]} {
set var {}
foreach {key text index} [$widget dump -text 1.0 end] {
set var "$var$text"
}
$widget edit modified 0
}
}
set myvar {}
text .mytext
bind .mytext <<Modified>> "textvariable .mytext myvar"
pack .mytext
#END OF EXAMPLE
...Best Regards,
=Adrian=
> Date: Thu, 21 May 2009 01:45:00 -0700 (PDT)
> From: adr...@satisoft.com
> Newsgroups: comp.lang.tcl
> Subject: Re: looking for -textvariable option for text widget ...
>
Thanks, Adrian. Simplicity has its place, and this approach passes the
test.
Rob.