[R-gui] gtree question
Antje
niederlein-rstat at yahoo.de
Thu Aug 7 15:10:43 CEST 2008
Hello there,
now that I started with gwidgets, I'll have several question (I hope not too
stupid ones).
I've started with a little application which uses a gpanedgroup to show a gtree
at the left side and something else on the other side.
Gtree works fine except the fact that it produces 3 columns though my offspring
function returns a data.frame with 1 column only (two columns then remain
without content).
Is there any way to delete these columns?
And another question:
If I expand my folders in the gtree and go deeper into the file structure, it
happens that the filenames are not displayed fully anymore because of too less
space. Can I make the gtree automatically horizontal scrollable (it can be
scrolled if I push the columns to a certain width).
Thanks a lot for any help!
Antje
The code:
# methods to update the file tree
# ------------------------------------------------
offspring <- function(path, user.data=NULL) {
if(length(path) > 0)
directory <- paste(getwd(),"/",paste(path,
collapse="/"),sep="",collapse="")
else
directory <- getwd()
files <- data.frame(dir(path=directory))
rownames(files) <- dir(path=directory, full.names = TRUE)
names(files)[1] <- "Files and Folders"
return(files)
}
hasOffspring <- function(children,user.data=NULL, ...) {
return(file.info(rownames(children))$isdir)
}
icon.FUN <- function(children,user.data=NULL, ...) {
info <- file.info(rownames(children))
x <- rep("file", length=nrow(children))
x[info$isdir] <- "directory"
return(x)
}
# ------------------------------------------------
# application
# ------------------------------------------------
mainwin <- gwindow(title = "TestApplication", visible = TRUE, name=title)
pg <- gpanedgroup(container = mainwin)
gtree(offspring, hasOffspring, icon.FUN = icon.FUN, container=pg)
gtext(cont = pg)
svalue(pg) <- 0.4
# ------------------------------------------------
More information about the R-SIG-GUI
mailing list