Question

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

Was it helpful?

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)

OTHER TIPS

library(gWidgets)
 options(guiToolkit="RGtk2")
library(RGtk2) ## needed

w <- gwindow("test")
g <- ggroup(cont=w)

e <- gtkEventBox()
getToolkitWidget(g)$packStart(e, expand=TRUE, fill=TRUE)
fr <- gframe("Label")                    # no container
e$add(widget@widget@block(fr))
e$modifyBg(GtkStateType["normal"], "yellow")

gbutton("click me", cont=fr)
glabel("a label", cont=fr)

appear the next Error:Error en checkPtrType(widget, "GtkWidget") : not found 'widget' obj

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top