[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!

The code:

# methods to update the file tree
# ------------------------------------------------
offspring <- function(path, user.data=NULL) {
	if(length(path) > 0)
       	directory <- paste(getwd(),"/",paste(path, 
       	directory <- getwd()

	files <- data.frame(dir(path=directory))

	rownames(files) <- dir(path=directory, full.names = TRUE)
  	names(files)[1] <- "Files and Folders"

hasOffspring <- function(children,user.data=NULL, ...) {

icon.FUN <- function(children,user.data=NULL, ...) {
	info <- file.info(rownames(children))
	x <- rep("file", length=nrow(children))
	x[info$isdir] <- "directory"
# ------------------------------------------------

# 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