开发者

gwidgets gtable refresh

开发者 https://www.devze.com 2023-03-17 04:57 出处:网络
I encounter the following problem: library(gWidgets) options(guiToolkit = \"RGtk2\") aa <- c(1,2,3) bb <- c(4,5,6)

I encounter the following problem:

library(gWidgets)
options(guiToolkit = "RGtk2")

aa <- c(1,2,3)
bb <- c(4,5,6)
cc <- cbind(aa,bb)
cc <-as.data.frame(cc)

t1 <- gtable(cc, container=TRUE)

I want to refresh the content of t1 with:

dd <- c(7,8,9)
dd <- as.data.frame(dd)

But when I run

t1[] <- dd

I receive开发者_如何学Python: Can't replace with fewer columns

Apostolos


To expand upon John's answer, here's an example.

#Data
cc <- data.frame(aa = 1:3, bb = 4:6)
dd <- data.frame(X = 7:9)

#Wigdets
win <- gwindow()
grp <- ggroup(container = win)
t1 <- gtable(cc, container = grp)

#Refresh widget
delete(grp, t1)
t1 <- gtable(dd, container = grp)

Note that the sample code in the question works fine under gWidgetstcltk; it's a purely GTK issue.


The gtk widget makes you pick the type of column at construction, so gtable doesn't let you have fewer columns or change column types. If you really want to do this, put the widget in a ggroup container, then delete and add a new widget.


If it is only about refreshing instead of completely changing its content I made very nice experience with something like this:

win <- gtable(data.frame(a=rnorm(100),b=runif(100)),container=T)
win[1,1] <- 5
win[1:10,2] <- 6
win[seq(dim(win)[1]),seq(dim(win)[2])] <- win[seq(dim(win)[1]),seq(dim(win)[2])] +1 

a complete 'refresh' might look like this:

win <- gtable(data.frame(a=rnorm(100),b=runif(100),d=FALSE),container=T)
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号