[R] Problem with tcltk listbox

Frank Gerrit Zoellner fzoellne at TechFak.Uni-Bielefeld.DE
Thu Feb 22 11:24:15 CET 2001


Hi!

I've got two problems with listboxes and selection:
I created a listbox, no problem. Then I bind the Button-1 of the mouse to the listbox to start some things by pressing the mousebutton. The proiblem is that as I click a item of the listbox this error occured:

Error in .Tcl(.Tcl.args(...)) : [tcl] bad listbox index "": must be active, anchor, end, @x,y, or a number.

Repaeting the selection, all works well. This looks quite strang to me.

The second thing is I have two listbox and I want to have the following action:
When I select a item in listbox A the corresponding item of listbox B should be highlited. Doing this, the event is one timestep behind. For example selecting first element in A, no slection in B becaus eof the error mentioned above. Then selecting the second item in A , the first of B is highlited.

Below the source fragments:

prot.listbox<-tklistbox(anzeigeframe,exportselection="0",selectmode="browse")
prot.yscroll<-tkscrollbar(anzeigeframe)

i <- 1
while (i <= length(resultset[,1]))
{
	tkinsert(prot.listbox,'end',paste(resultset[i,1],resultset[i,2],sep="."))
	i<- i+1
}
tkconfigure(prot.listbox,yscrollcommand=paste(.Tk.ID(prot.yscroll),"set"))
tkconfigure(prot.yscroll,command=paste(.Tk.ID(prot.listbox),"yview"))	
tkpack(prot.yscroll,prot.listbox,side="left",fill="y")
		
tkbind(prot.listbox,"<Button-1>",function()
{
  protas.listbox<-tklistbox(anzeigeframe,exportselection="0")
  protas.yscroll<-tkscrollbar(anzeigeframe)
  tkconfigure(protas.listbox,yscrollcommand=paste(.Tk.ID(protas.yscroll),"set"))
  tkconfigure(protas.yscroll,command=paste(.Tk.ID(protas.listbox),"yview"))
  sas.listbox<-tklistbox(anzeigeframe,exportselection="0")
  sas.yscroll<-tkscrollbar(anzeigeframe)
  tkconfigure(sas.listbox,yscrollcommand=paste(.Tk.ID(sas.yscroll),"set"))
  tkconfigure(sas.yscroll,command=paste(.Tk.ID(sas.listbox),"yview"))
  selection<- tkget(prot.listbox,tkcurselection(prot.listbox))
						  
  s1 <- substr(selection,1,4)
  s2 <- substr(selection,6,6)
 
	... doing something						  								  
	
										  i<-1
   while (i <= length(resultset[,1]))
   {
	tkinsert(protas.listbox,'end',paste(resultset[i,1],resultset[i,2],sep="."))
	tkinsert(sas.listbox,'end',resultset[i,3])
	i<-i+1
   }
						  	
   tkpack(protas.yscroll,protas.listbox,side="left",fill="y")
   tkpack(sas.yscroll,sas.listbox,side="left",fill="y")
						
   tkbind(protas.listbox,"<Button-1>",function()
	{
	  asselection<- tkcurselection(protas.listbox)
	  tkselection.clear(sas.listbox,0,"end")
          tksee(sas.listbox,asselection)                                 		  tkselection.set(sas.listbox,asselection)
	})
})


Thanks
-- 
Frank Gerrit Zoellner


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list