[R] Combo Box Wdget for Tcl/Tk under R

Peter Dalgaard BSA p.dalgaard at biostat.ku.dk
Wed Nov 6 18:04:59 CET 2002


Fabien.Fivaz at ie-zea.unil.ch writes:

> Hi,
> 
> I have two questions:
> 
> First, does anyone know how to put a combobox inside a GUI made with
> Tcl/Tk ? I think there isn't a simple way to do this (a command like
> tkcombobox()!), but is it possible to write a more complex code to
> achieve this ?

There's quite a bit of this kind of stuff going on in Tcl extensions.
Dirk Edelbuettel recently asked me about tabbed ("notebook") widgets,
which in this regard are quite similar.

The good news is that both the Bwidgets and Iwidgets extensions have
notebooks and combobox widgets, and both ship with the ActiveTcl
stuff. (A third package, Tix, also has them, but is not available with
ActiveTcl for some reason.)

The bad news is that there's no R interface to them, and that it may
not be entirely trivial to write one, although probably not extremely
hard either. 

I looked into Tix's notebook stuff, and figured out how
to blow some simple life into it, but the "solution" didn't quite do
the right thing. 

If you're interested, here's a rough description of the problem: The
Tcl code that I interfaced to creates internal subwidgets (one per
notebook page). This is not a problem in itself, but exposing the
widgets to R is, and of course you have to do that in order to
actually put stuff on the pages. You can wrap a tk widget
in the relevant object using .Tk.newwin(), but that's not quite
enough: you also have to register the subwidgets with the parent
widget or the garbage collector will do you in when the widget goes
out of scope. In Tix's notebook there is also an intermediate
widget "nbframe" that you should register as well.
 
> Second, when I put two listboxes in the same window or frame (even
> in two different toplevel windows), I cannot select things in the
> two lists together. I select things in the first list, ok, then,
> when I select things from the second list, the selection in the
> first disappears... Is it possible to select things at the "same"
> moment in two lists ?

You might want to take this type of question to one of the Tcl forums since
it is a generic problem, not restricted to usage in R. Here's what I
got in about 30s of Google-ing:

http://tcltk.free.fr/tcltkfaq.php3?idxquery=59
>>>>
The default for Tk's listbox widget exports its selection as the
X selection.  There can only be one of these at a time.

To turn off this behavior in Tk, use the -exportselection false when
you create the listbox.  Or, use the

option add *Listbox.exportselection false

command in the beginning of your script.

Thanks to David Herron  for this tip.
<<<<



-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list