Reputation: 7659
I'm writing a small database interface and want to use glayout. MWE:
require(gWidgets)
options("guiToolkit"="RGtk2")
### The bowl
win <- gwindow( "Fruits")
gui <- glayout( container = win )
### Fruit salad
gui[1,1] <- glabel( "Apple", cont = gui )
gui[1,2] <- gbutton( "Change", cont = gui )
nav1 <- function( gui )
{
svalue( gui[1,1] ) <- "Banana"
}
addHandlerClicked( gui[1,2], handler = function( h, ... )
{
nav1( gui )
})
The functionality seems to be there but I get an error (or is it a warning?) message
(R:14953): Gtk-CRITICAL **: IA__gtk_table_attach: assertion `child->parent == NULL' failed
I looked for solutions with rseek (nothing) and Google (nothing that I could relate to my specific problem). Any ideas what I could do to get rid of the messages? Or can I safely ignore them?
sessionInfo()
R version 2.15.2 (2012-10-26)
Platform: x86_64-pc-linux-gnu (64-bit)
...
other attached packages:
[1] gWidgetsRGtk2_0.0-81
Upvotes: 4
Views: 1849
Reputation: 7659
Based upon John's solution (thanks a lot...), I experimented a bit and found that creating a list that contains the indexed widgets gets around the problem. It also avoids the interim assignment that can be annoying when there are a number of widgets.
### The bowl
win <- gwindow( "Fruits")
gui <- glayout( container = win )
### Fruit salad
tmp <- list(
t1 = gui[1,1] <- glabel( "Apple", cont = gui ),
t2 = gui[1,2] <- gbutton( "Change", cont = gui ) )
nav1 <- function( tmp )
{
svalue( tmp$t1 ) <- "Banana"
}
addHandlerClicked( tmp$t2, handler = function( h, ... )
{
nav1( tmp )
})
Upvotes: 1
Reputation: 5700
It is in this line:
svalue( gui[1,1] ) <- "Banana"
that you get the error. If you break this up into two steps:
tmp <- gui[1,1]
svalue( tmp ) <- "Banana"
it goes away. This must have something to do with how R creates copies with replacement functions, but the widget referenced by gui[1,1] is a pointer. Anyways, not really sure about that.
Upvotes: 5