我正在考虑创建一个带有2个复选按钮的小工具,每个按钮都在tkframe中。通过单击第一个复选按钮,我希望第一个框将展开以显示更多行的选项。但是当点击第二个复选按钮时,我希望第二个框架会扩展,但第一个框架会缩小到只包括第一个复选按钮。这就像是通过单击复选按钮激活了几条隐藏线。有人知道怎么做吗?
谢谢,DD
发布于 2013-03-28 21:08:01
你可以在tcltk的gWidgets (或者github上的gWidgets2,你可以在https://github.com/jverzani/gWidgets2tcltk/blob/master/R/gexpandgroup.R上看到它是如何完成的)中获得类似这样的东西。以下是模式:
library(gWidgets)
options(guiToolkit="tcltk")
lorem <- "lorem ipsum dolor sit amet, consectetur adipiscing
elit. Suspendisse tempus aliquam ante, at malesuada tellus
vulputate at. Morbi ac diam augue, vel bibendum lorem.
Curabitur ut est molestie leo sagittis vestibulum.
"
w <- gwindow()
size(w) <- c(800, 400)
g <- ggroup(cont=w, horizontal=FALSE)
expand1 <- gexpandgroup("frame 1", cont=g, anchor=c(-1,1))
expand2 <- gexpandgroup("frame 2", cont=g, anchor=c(-1,1))
visible(expand2) <- FALSE
## put stuff into expanding groups
glabel(lorem, cont=expand1)
glabel(lorem, cont=expand2)
callback <- function(h,...) {
print("click 2")
if(visible(expand2) & visible(expand1))
visible(expand1) <- FALSE
}
addHandlerChanged(expand2, callback)扩展组小部件只有在堆叠时才能工作,而不是并排工作。使用纯tcltk将其集成到GUI中并不是不可能的。
https://stackoverflow.com/questions/15676365
复制相似问题