有时我有一个下拉框,只有一个项目可供选择,但这个项目可能是一个带空格的字符串。我如何在R中做到这一点?以下是问题所在:
library(tcltk2)
root<-tktoplevel()
v <- tclVar()
d <- tk2combobox(root, textvariable=v)
tkpack(d)
# works
tkconfigure(d, values=c("a string with spaces", "a second string"))
# inserts four items instead of one
tkconfigure(d, values=c("a string with spaces"))任何提示都很感谢!
发布于 2010-12-05 01:13:39
试试这个:
spaceystr <- tclVar("a string with spaces")
tkconfigure(d, textvariable = spaceystr)还可以使用另一种方法,将字符串实际放在下拉列表中,而上面的方法并不这样做:
tkconfigure(d, values=as.tclObj("a string with spaces", drop=FALSE))这一点在TclInterface的帮助页面中有所暗示,但并未实际说明。
https://stackoverflow.com/questions/4353361
复制相似问题