Search code examples
rgwidgets

How i can change the background color of gframe in gWidgets?


I am building a GUI in gWidgets R, but I need to change background color of a gFrame from "gray" to "yellow". Thanks


Solution

  • It should be something like this

    library(RGtk2); 
    getBlock(fr)$modifyBg(GtkStateType["normal"], "yellow")
    

    but that only does the outer most frame. Unfortunately, to do this you need to pack the container into an event box and color that. Here is the pattern:

    library(gWidgets)
    options(guiToolkit="RGtk2")
    library(RGtk2) ## needed
    
    w <- gwindow("test")
    g <- ggroup(cont=w)
    
    e <- gtkEventBox()
    getWidget(g)$packStart(e, expand=TRUE, fill=TRUE)
    fr <- gframe("Label")                    # no container
    e$add(getBlock(fr))
    e$modifyBg(GtkStateType["normal"], "yellow")
    
    gbutton("click me", cont=fr)
    glabel("a label", cont=fr)