[R] tk combobox question

JeeBee JeeBee at troefpunt.nl
Wed Aug 9 23:19:25 CEST 2006


I think you want something like this:

  require(tcltk) || stop("Package tcltk is not available.")
  version.BWidget <- tclvalue(tclRequire("BWidget"))

  modify_command <- function() {
    print("Hey, I'm modified...")
  }

  tt <- tktoplevel()

  values = c("foo", "bar", "jeebee")
  combo <- tkwidget(tt, "ComboBox", "-modifycmd", 
                    modify_command, values=values)
  tkgrid(combo)

> How can I get the index of the selected item in an Iwidgets combobox? Till now I 
> am only able to get the contents of the selected combobox item.

For BWidget:
  as.numeric(tclvalue(tcl(combo,"getvalue")))+1

I haven't used Iwdigets yet...

JeeBee.



More information about the R-help mailing list