2

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.

4

1 回答 1

2

这是普通的 Tcl,而不是 R 语法,但您想将小部件的状态设置为readonly. 这将禁止用户修改该值,但它仍然尊重对文本变量的更改。您不需要绑定任何东西,用户无法专注于小部件。

set value 0
entry .e -textvariable value -state readonly
button .b -text incr -command {incr value}
pack .e .b
于 2013-08-30T14:40:04.513 回答