In R-1.7.1, I used to be able to append a character vector to a 'tklistbox' with e.g. listio <- tklistbox( tktoplevel(), font='Courier', height=20, width=20, setgrid=TRUE) tkinsert( listio, 'end', letters[1:3]) tkpack( listio,side='left', expand=TRUE, fill='both') and three items would be added to 'listio'. This doesn't work in R-devel-- it looks as if only a single paste-collapsed item is added. This might even be intentional, but seems undesirable! The old behaviour can be obtained by reproducing the R 1.7.1 instructions: .Tcl( .Tcl.args( listio, 'insert', 'end', letters[1:3])) Mark ******************************* Mark Bravington CSIRO (CMIS) PO Box 1538 Castray Esplanade Hobart TAS 7001 phone (61) 3 6232 5118 fax (61) 3 6232 5012 Mark.Bravington@csiro.au # r-bugs@r-project.org --please do not edit the information below-- Version: platform = i386-pc-mingw32 arch = i386 os = mingw32 system = i386, mingw32 status = alpha major = 1 minor = 8.0 year = 2003 month = 09 day = 22 language = R Windows 2000 Professional (build 2195) Service Pack 3.0 Search Path: .GlobalEnv, package:methods, package:ctest, package:mva, package:modreg, package:nls, package:ts, package:handy, package:debug, mvb.session.info, package:mvbutils, package:tcltk, Autoloads, package:base
tkinsert (PR#4289)
2 messages · Mark Bravington, Peter Dalgaard
Mark.Bravington@csiro.au writes:
In R-1.7.1, I used to be able to append a character vector to a 'tklistbox' with e.g. listio <- tklistbox( tktoplevel(), font='Courier', height=20, width=20, setgrid=TRUE) tkinsert( listio, 'end', letters[1:3]) tkpack( listio,side='left', expand=TRUE, fill='both') and three items would be added to 'listio'. This doesn't work in R-devel-- it looks as if only a single paste-collapsed item is added. This might even be intentional, but seems undesirable! The old behaviour can be obtained by reproducing the R 1.7.1 instructions: .Tcl( .Tcl.args( listio, 'insert', 'end', letters[1:3]))
So someone found out...
This is just about the only incompatible change with the new Tcl_Objv
interface. The old way was one of those things that looked like a good
idea when written (to support exactly that situation), but never
really was. It made it difficult to pass character vectors as single
entities where that was desired. I.e., the new behaviour is a feature,
not a bug.
This leaves a generic problem with R programming: Given letters[1:3],
how to generate
tkinsert(listio, "insert", 'end', letters[1], letters[2], letters[3])
Probably the neatest way is
do.call("tkinsert", c(list(listio, "insert", "end"), as.list(letters[1:3])))
or maybe
i.end <- function(...) tkinsert(listio, 'insert', 'end', ...)
do.call("i.end", as.list(letters[1:3]))
An alternative is to use the listvariable techniques and maintain
things on the R side:
x <- tclVar()
listio <- tklistbox(tktoplevel() , listvariable=x)
tkpack(listio)
tclObj(x) <- mylist <- c("foo","bar","baz")
mylist <- c(mylist,letters[1:3])
tclObj(x) <- mylist
O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk) FAX: (+45) 35327907