1

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

user1021713
  • 2,133
  • 8
  • 27
  • 40
narteaga
  • 147
  • 2
  • 12
  • 1
    Please help us help you by providing us with a reproducible example (i.e. code and example data), see http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example for details. – Paul Hiemstra Jun 06 '13 at 04:17
  • This isn't part of the gWidgets API, but usually can be performed with the underlying toolkit. Which toolkit are you using? RGtk2, tcltk, Qt? – jverzani Jun 06 '13 at 16:30

2 Answers2

1

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)
jverzani
  • 5,600
  • 2
  • 21
  • 17
  • thanks for your answer i run your example but appear the next Error in R: `"Error: in checkPtrType(widget, "GtkWidget") : not found the "getBlock" function"` and `"Error: not found the "getWidget" function"` – narteaga Jun 11 '13 at 14:04
  • Sorry, those were introduced in gWidgets2. SHould have tested under the other. Try `getToolkitWidget` for `getWidget` and digging into the object via `widget@widget@block` for `getBlock`. – jverzani Jun 11 '13 at 18:22
  • now appear yellow the area of ggroup but i need only in gframe – narteaga Jun 11 '13 at 21:08
0
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

narteaga
  • 147
  • 2
  • 12