[R] Problem with tcltk listbox
Peter Dalgaard BSA
p.dalgaard at pubhealth.ku.dk
Thu Feb 22 12:25:59 CET 2001
Frank Gerrit Zoellner <fzoellne at TechFak.Uni-Bielefeld.DE> writes:
> 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
> 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.
> asselection<- tkcurselection(protas.listbox)
> 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.
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
More information about the R-help