[R] tcltk: multiple listboxes, selection

JeeBee jeebee at troefpunt.nl
Sat Oct 21 22:52:39 CEST 2006


Dear list,

I have multiple (BWidget) listboxes in the same toplevel window.
The problem is, if I select (by left clicking) on one of those
listbox elements, the current selection in the *other* listboxes is
cleared!
Anybody knows how I can prevent this?

Here's my code (sorry not complete):
(E.g. If I select an X value, I'd lose the Y value I selected before)

gui.create.tab.general <- function(tt) {
  # Network topology
  frame.1 <- tkframe(tt)
  combo_topology <- tkwidget(frame.1, "ComboBox", values = infras,
    editable = FALSE)
  tcl(combo_topology, "setvalue", "first")
  tkgrid(tklabel(frame.1, text="Network topology"), combo_topology)
  tkgrid(frame.1, sticky = "w")
  # X values
  frame.x <- tkwidget(tt, "labelframe", text = "X value")
  tl.x <- tklistbox(frame.x, height = length(xvals) / 2,
                width = 50, selectmode = "browse", background = "white")
  for(i in seq(from=1, to=length(xvals), by=2)) {
    tkinsert(tl.x, "end", xvals[[i]])
  }
  tkselection.set(tl.x, 0)
  tkgrid(tl.x, sticky="news")
  # Y values
  frame.y <- tkwidget(tt, "labelframe", text = "Y value(s)")
  tl.y <- tklistbox(frame.y, height = 20, #length(yvals) / yvals.field.count,
                yscrollcommand=function(...) tkset(scr.y,...),
                width = 50, selectmode = "extended", background = "white")
  scr.y <- tkscrollbar(frame.y, repeatinterval = 5,
    command = function(...) tkyview(tl.y, ...))
  for(i in seq(from=1, to=length(yvals), by=yvals.field.count)) {
    tkinsert(tl.y, "end", yvals[[i]])
  }
  tkselection.set(tl.y, 0)
  tkgrid(tl.y, scr.y, sticky="news")
  # Packing
  tkgrid(frame.x, frame.y, sticky="news")
         #side = "left", fill = "both", expand = TRUE)
}



More information about the R-help mailing list