jverzani / gWidgets2

Rewrite of gWidgets
35 stars 9 forks source link

`gtable` name gets reset on `[<- ` #71

Closed landroni closed 10 years ago

landroni commented 10 years ago

Consider:

w <- gwindow("gtable example", visible=FALSE)
g <- gvbox(cont=w)
tbl <- gtable(names(mtcars), cont=g, expand=TRUE, fill=TRUE)
visible(w) <- TRUE

Now set the table header name:

names(tbl) <- "Variables"

And notice that the name gets reset on reinitializing the table items:

tbl[] <- head(names(mtcars))

This seems like a bug. Could it be fixed, so that the header name is never dropped?

jverzani commented 10 years ago

Changing it isn't hard, but the problem is one can reshape the table when set via [<-, so the names may not be apt or even the right length. I'd suggest a wrapper to store the names, call [<- and then reset the names if you do this a lot.

landroni commented 10 years ago

Oh, I seem to have found a workaround:

tbl[] <- data.frame("Variables"=head(names(mtcars)))

Should this be documented?