title: getting values in R from tkentry() widgets
body: <p>I'm trying to create a small interactive window in which user (for now me) can enter specific information regarding power calculations (test name, number of groups, type of data) in order to perform the correct kind of power calculation. I know how to do this directly in R, but I want to create a module for others to use who are generally less interested or competent with code and stats, so they can do some simple pre-test power calculations for a better test design. </p>
  
  <p>I'm stuck, I keep getting similar error messages that I don't really understand. here's my code:</p>
  
  <pre><code>&gt;require(tcltk)
  &gt;t3&lt;- tktoplevel()
  &gt;tktitle(t3)&lt;-"Statistical power"           
  ##create buildingblocks
  #define appearance of heading, sub, questions
  &gt;fontHead&lt;-tkfont.create(family="times",size=16,weight="bold")       
  &gt;fontSub&lt;-tkfont.create(family="times",size=14,weight="bold")
  &gt;fontQ&lt;-tkfont.create(family="times",size=14)
  &gt;fontQ.s&lt;-tkfont.create(family="times",size=12)
  &gt;heading.m   &lt;-tklabel(t3,text="This module will give you insight in the statistical power requirements of your test",font=fontHead)
  &gt;heading.s   &lt;-tklabel(t3,text="Please answer the following questions:",font=fontSub)
  &gt;Q1          &lt;-tklabel(t3,text="What is the name of your test?",font=fontQ)
  &gt;filename    &lt;-tclVar("Your test")             # this I have seen at**
  &gt;e.Q1        &lt;-tkentry(t3,width=30,textvariable=filename)
  &gt;submit.name &lt;-function(){                      # this I have seen at**
  &gt;  filename&lt;&lt;- as.character(tclvalue(e.Q1)) # this I have seen at**
  &gt;  e &lt;- parent.env(environment())           # this I have seen at**
  &gt;  e$filename &lt;- filename  }                # this I have seen at**
  &gt;b.Q1.sub    &lt;-tkbutton(t3,text="Submit",command=submit.name) # this I have seen at**      
  # creating the widget    
  &gt;tkgrid(heading.m,columnspan=6)                 
  &gt;tkgrid(tklabel(t3,text="     "))
  &gt;tkgrid(heading.s, columnspan=6, sticky="w")
  &gt;tkgrid(Q1,row=4,column=0,rowspan=1,columnspan=2,sticky="w")                       
  &lt;tkgrid(e.Q1,row=4,column=2,rowspan=1,columnspan=3,sticky="ew")
  &lt;tkgrid(b.Q1.sub,row=4,column=5,rowspan=1,columnspan=1,sticky="ew")
  </code></pre>
  
  <p>** I copied this solution from Greg Snow's answer to the following question (<a href="https://stackoverflow.com/questions/16847621/get-data-out-of-a-tcltk-function">Get data out of a tcltk function</a>) it doesn't work for me unfortunately. Running my code I get this error message:
  "Error in structure(.External(.C_dotTclObjv, objv), class = "tclObj") : 
    [tcl] can't read ".32.4 ": no such variable."</p>
  
  <p>above is an example, what I also want to achieve is for the user to enter the amount of groups and whether the data is proportional or scale. here's the code:</p>
  
  <pre><code>   &gt;Q2          &lt;-tklabel(t3,text="How many test-groups do you have?",font=fontQ)
     &gt;groups      &lt;-tclVar("")
     &gt;e.Q2        &lt;-tkentry(t3,textvariable=groups)  # I want to link this answer to buttonclick at Q3 for determining type of test 
     &gt; #groups      &lt;-as.numeric(tclvalue(e.Q2))  # running this produced this message *** 
    &gt;#groups      &lt;-function(){
                 as.integer(tclvalue(e.Q2))
                }   ## running this produced this message****
  &gt; Q3          &lt;-tklabel(t3,text="What type of differences do you want to test for?",font=fontQ)
   l.Q3.prop   &lt;-tklabel(t3,text="Proportional differences (e.g. click through rate, bounce rate, gender rate, etc)",font=fontQ.s)
      l.Q3.scal   &lt;-tklabel(t3,text="Scaled differences (e.g. converted value, age, numer of sessions before conversion, etc)",font=fontQ.s)
      onok.prop   &lt;-function() {        
                  groups&lt;-as.numeric(tclvalue(e.Q2))
                  test&lt;-ifelse(unlist(groups)&gt;2,"Chisq","prop")               
                  return(test)
                  tkdestroy(t3) }                                     
      onok.scal        &lt;-function(){ 
                  groups&lt;-as.numeric(tclvalue(e.Q2))
                  test&lt;-ifelse(unlist(groups)&gt;2,"Anova","t-test")              return(test)
                  tkdestroy(t3) }                                      
      b.Q3.prop   &lt;-tkbutton(t3,text="Proportional",command=onok.prop) 
      b.Q3.scal   &lt;-tkbutton(t3,text="Scale",command=onok.scal)        
  tkgrid(tklabel(t3,text="     "))
  tkgrid(Q2,row=6,column=0,rowspan=1,columnspan=4, sticky="w")
  tkgrid(e.Q2,row=6,column=4,rowspan=1,columnspan=2,sticky="ew")
  tkgrid(tklabel(t3,text="     "))
  tkgrid(Q3,sticky="w")
  tkgrid(l.Q3.prop,row=9,column=0,rowspan=1,columnspan=4, sticky="w" )
  tkgrid(b.Q3.prop,row=9,column=4,rowspan=1,columnspan=2, sticky="ew")                         
  tkgrid(l.Q3.scal,row=10,column=0,rowspan=1,columnspan=4, sticky="w" )
  tkgrid(b.Q3.scal,row=10,column=4,rowspan=1,columnspan=2, sticky="ew")
  </code></pre>
  
  <pre>
  *** Error in structure(.External(.C_dotTclObjv, objv), class = "tclObj") : 
    [tcl] can't read ".19.6 ": no such variable. (or variations on this with different numbers)
  </pre>
  
  <pre>
  **** Error in as.integer(substitute(groups)) : 
    cannot coerce type 'symbol' to vector of type 'integer' (or variations such as " ... type 'closure' to vector of type 'integer' )
  </pre>
  
  <p>I would really appreciate some practical help here, as Googling the error messages produced either solutions which got me to new erro messages (at least that felt like progress) but also sometimes no results (which surprised me). Calling the help files related to things like environment, get, mget, deparse, function etc from R actually leaves me even more puzzled than before I read them.</p>
  
  <p>thanks in advance,
  yours</p>