[R-gui] [R Gui]Moving thru fields

James Wettenhall wettenhall at wehi.edu.au
Fri Apr 23 04:29:24 CEST 2004

 On Thu, 22 Apr 2004, Erin Hodgess wrote:

> Hello again!
> I have several entry fields.
> I want to check each field as I go along
> Then I want to move to the next field.
> How to I move to the next field, please?
> Thanks so much!
> >From a sorely puzzled
> Erin
> mailto: hodgess at gator.uhd.edu


It depends what you mean by next.  If you mean next in the 
tab-order (i.e. when the user presses the 'Tab' key), I don't 
know how to do that.  But it might help you to define a 
list of tclVars and a list of widgets...

tclVarList <- list()
for (i in (1:NumEntryFields))
  tclVarList[[i]] <- tclVar("Initial value")

EntryList <- list()
for (i in (1:NumEntryFields))
  EntryList[[i]] <- tkentry(tt,textvariable=tclVarList[[i]])

Then moving to the next field as defined by the list shouldn't 
be too hard...

What about assigning callback functions to a list of widgets?  
Is it considered reasonable R coding style to have a list of 
functions?  I didn't think of this when I implemented a list of 
widgets, so I did something like this:

for (i in (1:NumWidgets))
  " <- function() {onBrowse(",i,",)}",sep="")))


The idea is that (unless I'm mistaken), a Tcl callback function 
for something like a button-press in R-Tcl/Tk shouldn't have any 
arguments, so here I used a function onBrowse1() with no 
arguments to call a function onBrowse(1), and onBrowse2() to
call onBrowse(2) etc.  Does that make sense?


James Wettenhall                                  Tel: (+61 3) 9345 2629
Division of Genetics and Bioinformatics           Fax: (+61 3) 9347 0852
The Walter & Eliza Hall Institute         E-mail: wettenhall at wehi.edu.au
 of Medical Research,                     Mobile: (+61 / 0 ) 438 527 921    
1G Royal Parade,
Parkville, Vic 3050, Australia

More information about the R-SIG-GUI mailing list