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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Frank Gerrit Zoellner <fzoellne at TechFak.Uni-Bielefeld.DE> writes:> 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....> 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) > })I think you're getting exactly what you ask for... If you bind a query to Button-1, which is also the button to make selections with, then there's a question of the order in which the two things should happen. As it happens, user bindings are handled before system bindings, so your tkcurselection() gets the old selection. Binding to <ButtonRelease-1> seems to work rather better. PS. You'd have done us all a service by creating a small *directly executable* example of your problem. E.g. library(tcltk) tt<-tktoplevel() tl<-tklistbox(tt) tkpack(tl) tkinsert(tl, "end", month.name) tkbind(tl, "<Button-1>", function()print(tkcurselection(tl))) # to fix: tkbind(tl, "<Button-1>", "") tkbind(tl, "<ButtonRelease-1>", function()print(tkcurselection(tl))) -- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
No problem. This list is for helping all with R. Mfg -- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._