繁体   English   中英

R tcltk,tkframe扩展

[英]R tcltk, tkframe expansion

我正在考虑创建一个带有2个复选按钮的小部件,每个复选按钮在tkframe中。 我希望通过单击第一个检查按钮,第一帧会扩展以显示更多行的选项。 但是,当单击第二个检查按钮时,我希望第二个框架会扩展,但第一个框架会减少到仅包含第一个检查按钮。 就像通过单击复选框激活了几条隐藏线一样。 有谁知道如何做到这一点?

谢谢,DD

您可以在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)

expandgroup小部件实际上仅在堆叠时才有效,而不能并排使用。 将其与纯tcltk集成到GUI中并非没有可能。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM