Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

looking for -textvariable option for text widget ...

23 views
Skip to first unread message

Sp...@controlq.com

unread,
May 20, 2009, 11:53:39 AM5/20/09
to

I suppose the man page is definitive when it comes to the text widget.
I'm a bit surprised, however that the text widget doesn't seem to have a
variable or array mapping (-textvariable, -varname etc.)

Any pointers or must I use a [.txt get] widget command to get the value?

Cheers,
Rob Sciuk

Bryan Oakley

unread,
May 20, 2009, 12:20:37 PM5/20/09
to

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.

suchenwi

unread,
May 20, 2009, 12:37:06 PM5/20/09
to
On 20 Mai, 18:20, Bryan Oakley <oak...@bardo.clearlight.com> wrote:
> That being said, I think there's code to emulate a textvariable on the
> wiki. It's doable with read traces.

http://wiki.tcl.tk/1917

Sp...@controlq.com

unread,
May 20, 2009, 5:44:23 PM5/20/09
to
On Wed, 20 May 2009, suchenwi wrote:

> 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.

adr...@satisoft.com

unread,
May 21, 2009, 4:45:00 AM5/21/09
to

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=

Sp...@controlq.com

unread,
May 21, 2009, 10:59:40 AM5/21/09
to
On Thu, 21 May 2009, adr...@satisoft.com wrote:

> 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.

0 new messages