首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >R tcltk,tkframe扩展

R tcltk,tkframe扩展
EN

Stack Overflow用户
提问于 2013-03-28 15:27:36
回答 1查看 207关注 0票数 1

我正在考虑创建一个带有2个复选按钮的小工具,每个按钮都在tkframe中。通过单击第一个复选按钮,我希望第一个框将展开以显示更多行的选项。但是当点击第二个复选按钮时,我希望第二个框架会扩展,但第一个框架会缩小到只包括第一个复选按钮。这就像是通过单击复选按钮激活了几条隐藏线。有人知道怎么做吗?

谢谢,DD

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-03-28 21:08:01

你可以在tcltk的gWidgets (或者github上的gWidgets2,你可以在https://github.com/jverzani/gWidgets2tcltk/blob/master/R/gexpandgroup.R上看到它是如何完成的)中获得类似这样的东西。以下是模式:

代码语言:javascript
复制
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中并不是不可能的。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15676365

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档