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

Creating a non-user-editable text widget

6 views
Skip to first unread message

Stephen Kane

unread,
Dec 19, 2001, 6:09:12 AM12/19/01
to
Hi all,

I'm trying to discover how to create a text widget that can have
messages placed in it by the tcl script, but cannot be edited by the
user. The only options that I know of are -state normal or -state
disabled which means that not even the script can place new messages
there. I hope it is clear to readers what I am trying to do. Can
anyone help on this?

Cheers,

Stephen

HD

unread,
Dec 19, 2001, 1:29:18 PM12/19/01
to
sk...@stsci.edu (Stephen Kane) wrote in message news:<62d5ff20.01121...@posting.google.com>...

You could create a proc like this:

proc updateWidget {t msg} {
$t config -state normal
$t insert end $msg
$t config -state disabled
$t see end
}

Then your script can write to the widget using this proc, but the user can't.

--
Hugh Dunne ### hdunne "AT" ciena "DOT" com

Tyler

unread,
Dec 19, 2001, 1:33:51 PM12/19/01
to
Well, this is really simple.
Everytime you do the insert, change the state to normal. Once done
with the insert, change the state back to disabled.

Hope this will do the trick.

sk...@stsci.edu (Stephen Kane) wrote in message news:<62d5ff20.01121...@posting.google.com>...

rand mair fheal

unread,
Dec 19, 2001, 7:58:55 PM12/19/01
to
In article <e0357ae0.0112...@posting.google.com>,
ta...@pacbell.net (Tyler) wrote:

>Well, this is really simple.
>Everytime you do the insert, change the state to normal. Once done
>with the insert, change the state back to disabled.

you still want to do somethings with text like mouse selection
you can play witrh the bindings

bind widget <Keypress> {break}

Steve Offutt

unread,
Dec 19, 2001, 8:21:56 PM12/19/01
to
"Stephen Kane" <sk...@stsci.edu> wrote in message
news:62d5ff20.01121...@posting.google.com...

Stephen,

In addition to the previous replies to your question, you may
find more information on the Wiki:

http://mini.net/tcl/1152.html

"Read-only Text Widget"

HTH

Steve


--
Posted from dial194.sunflower.org [209.16.214.194]
via Mailgate.ORG Server - http://www.Mailgate.ORG

Chris Nelson

unread,
Jan 3, 2002, 5:37:53 PM1/3/02
to
Tyler wrote:
>
> Well, this is really simple.
> Everytime you do the insert, change the state to normal. Once done
> with the insert, change the state back to disabled.

Better to change it back to what it was than to disabled:

set oldState [$text cget -state]
$text configure -state normal
$text insert ...
$text configure -state $oldState

Also, here's a little trick to let user's scroll around and not jump
back to the end on them when adding text:

# Determine if bottom of the text's contents is visible.
# If not, we won't scroll after inserting new text.
if { [lindex [$text yview] 1] == 1} {
set scroll 1
} else {
set scroll 0
}

# Add the text.
$text insert end $line\n

# Update view, if appropriate.
if {$scroll} {
$text see end
}

Chris
--
As MIT is not "Massachusetts" neither is RPI "Rensselaer"

0 new messages