[R] tkinsert

From: claude.josse <claude.josse_at_wanadoo.fr>
Date: Sat 12 Aug 2006 - 01:14:42 EST


Dear List,

I'm looking for some informations about the function "tkinsert()". I d'like to write lot of command in my text window and after to evaluate it with a button "Submit" for example, but i have some problems:

here a exemple of my code:
1) My first problem

tt=tktoplevel()
txt=tktext(tt,height=40)
tkpack(txt)

var1=paste("x=2")
tkinsert(txt,"0.0",var1)

var2=paste("a=mean(c(1,2,3))")
tkinsert(txt,"end",var2)

But in my text window I have :

x=2a=mean(c(1,2,3))

I d'like to have something like:
x=2

a=mean(c(1,2,3))

2)My second problem,

I use the run function that i have found in R TCLTK example Evaluating R Code From A Text Window in R TclTk:   run <- function() {
  code <- tclvalue(tkget(txt,"0.0","end"))   e <- try(parse(text=code))
  if (inherits(e, "try-error")) {
    tkmessageBox(message="Syntax error",

                 icon="error")

    return()
   }
   cat("Executing from script window:",

      "-----", code, "result:", sep="\n")    print(eval(e))
}
topMenu <- tkmenu(tt)
tkconfigure(tt, menu=topMenu)
fileMenu <- tkmenu(topMenu, tearoff=FALSE) tkadd(topMenu, "command", label="Run",

      command=run)
But when I run a=mean(c(1,2,3)) I have the result on my R console but i can't access to the result. If i write a, R don't know "a".

Thanks a lot,
and so sorry for my poor english, i hope you understand my problems...

Julie.

        [[alternative HTML version deleted]]



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Sat Aug 12 01:20:40 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Sat 12 Aug 2006 - 22:19:20 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.