Search code examples
rgwidgets

Dynamically change border of gbutton in R


I'm using the gWidgets package in R (specifically the RGtk2 toolkit). I've created some gbuttons and you can specify on creation border=FALSE or border=TRUE. Is there a way to dynamically change this option? I know you can change the text on a button using svalue but I can't find a way to change this

win <- gwindow()
gg <- ggroup(cont = win)
gb1 <- gbutton("TRUE", border = TRUE, cont = gg)
gb2 <- gbutton("FALSE", border = FALSE, cont = gg)

Is there a way to dynamically make gb2 look like gb1?


Solution

  • You can do this by manipulating the underlying RGtk object, for example:

    library(gWidgets)
    options(guiToolkit="RGtk2")
    library(RGtk2) ## needed to call underlying methods through $
    b <- gbutton("some button", cont=gwindow())
    
    getToolkitWidget(b)$setRelief("none") ## one of GtkReliefStyle values
    

    I took the border argument out of gWidgets2, as I didn't know it was useful.