Skip to content
Prev 981 / 1236 Next

[R-gui] gWidgets update certain arguments

Stefan JansevanRensburg <Stefan.JansevanRensburg <at> resbank.co.za> writes:
variable (in a data.frame)
I want the default to, from
selected variable, respectively.
variable from the drop-down list?

There are no methods in gWidgets to update the spinbutton values. (Should be
though. What is the right API, perhaps [<- checking that the sequence is
regular?) In the meantime, I can think of a few possibilities:

1) pack the spinbox in a ggroup container, then to update it delete the old one,
add a new one. Any handlers would need to be added again, so you would need to
do some bookkeeping. With a default handler, it would look like this:

library(gWidgets)
w <- gwindow()
g <- ggroup(cont = w)
sb <- gspinbutton(cont = g, handler = defaultHandler)
delete(g, sb)
[1] TRUE
sb1 <- gspinbutton(from=1, to = 10, by = .5, cont = g, 
   handler=defaultHandler) # replace with another


2) if you are using just one toolkit, say RGtk2, then you can access the toolkit
object with getToolkitWidget and update that. For RGtk2, this might look like
the following:

library(gWidgets)
options(guiToolkit="RGtk2")
w <- gwindow()
sb <- gspinbutton(from=0,to=100, by = 10, value=20, cont = w)

## Gtk code to modify
library(RGtk2)
sbwidget <- getToolkitWidget(sb)
sbwidget$setRange(0,50)
sbwidget$setIncrements(1,5)
sbwidget$setValue(10)
satisfactory, since it simple keeps