What can I do against a Gtk-CRITICAL error?
I am writing a small database frontend 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 this a warning?)
(R:14953): Gtk-CRITICAL **: IA__gtk_table_attach: assertion `child->parent == NULL' failed
I have searched for solutions with rseek (nothing) and google (nothing 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
source to share
In this line:
svalue( gui[1,1] ) <- "Banana"
you will get an error. If you split this into two steps:
tmp <- gui[1,1]
svalue( tmp ) <- "Banana"
He's leaving. This should have something to do with how R makes copies using overridden functions, but the widget referenced by gui [1,1] is a pointer. Not really sure about that anyway.
source to share
Based on John's solution (thanks a lot ...) I experimented a bit and found that creating a list containing indexed widgets turns out to be a problem. It also avoids intermediate assignments, which can be annoying when there are multiple 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 )
})
source to share