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
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
Hope this will do the trick.
sk...@stsci.edu (Stephen Kane) wrote in message news:<62d5ff20.01121...@posting.google.com>...
>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}
Stephen,
In addition to the previous replies to your question, you may
find more information on the Wiki:
"Read-only Text Widget"
HTH
Steve
--
Posted from dial194.sunflower.org [209.16.214.194]
via Mailgate.ORG Server - http://www.Mailgate.ORG
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"