Reputation: 4895
I am looking for some way to forbid users to change value in a text box with tcltk and R.
Here is what I have done : I want to forbid users to change the value in the first box.
library(tcltk)
tt <- tktoplevel()
v <- tclVar("32 200 700")
entry.1 <-tkentry(tt, width = "50", textvariable = v)
tkbind(entry.1, "<Key>", function()tkfocus(entry.2))
tkgrid(entry.1, row=1, column=0)
v2 <- tclVar("")
entry.2 <-tkentry(tt, width = "50", textvariable = v2)
tkgrid(entry.2, row=2, column=0)
It seems to work but key's native action is done before bound action.
How can I solve this problem ?
I don't want to use tklabel
because it can't bring borders to the text.
Upvotes: 2
Views: 1038
Reputation: 246774
This is plain Tcl, not R syntax, but you want to set the widget's state to readonly
. That will forbid the user from modifying the value, but it still respects changes to the text variable. You don't need to bind anything, the user cannot focus on the widget.
set value 0
entry .e -textvariable value -state readonly
button .b -text incr -command {incr value}
pack .e .b
Upvotes: 2