r - How to set font for a gcheckbox object -
r - How to set font for a gcheckbox object -
the font
method in gwidgets not seem work gcheckbox
(with rgtk2 toolkit). in next code styling applied correctly glabel
object fails gcheckbox
.
library(gwidgets) w <- gwindow("test", height=50) g <- ggroup(container=w) cb1 <- gcheckbox(text="one", container=g) cb2 <- gcheckbox(text="two", container=g) label <- glabel("text", container=g) font(cb2) <- list(size=20) font(label) <- list(size=20)
is there way create work?
there isn't in api setting font, can hack in:
## setfont properties setfont_hack <- function(cb, spec) { require(rgtk2) widget <- gettoolkitwidget(cb)$getchildren()[[1]] font_descr <- pangofontdescriptionnew() if(!is.null(spec$weight)) font_desc$setweight(pangoweight[spec$weight]) if(!is.null(spec$style)) font_desc$setstyle(pangostyle[spec$style]) if(!is.null(spec$scale)) font_desc$setsize(spec$scale * pango_scale) if(!is.null(spec$family)) font_desc$setfamily(spec$family) widget$modifyfont(font_desc) if(!is.null(spec$color)) widget$modifyfg(gtkstatetype[1], spec$color) } cb <- gcheckbox("label", cont=gwindow()) setfont_hack(cb, list(weight="bold", color="blue"))
it should plenty phone call font<- on label part of checkbox (just gettoolkitwidget(cb)$getchildren()[[1]]), inheritance isn't set right. (s3 classes aren't promoted s4.)
in gwidgets2rgtk2
isn't much better, there can this:
require(rgtk2) label <- gettoolkitwidget(cb)$getchildren()[[1]] cb$set_rgtk2_font(label, list(weight="bold"))
r fonts gwidgets
Comments
Post a Comment