Events and the Listbox widget

Jake Baker jbaker at ummelec.com
Tue Oct 3 11:30:02 EDT 2000


Use list.bind('<<ListboxSelect>>') instead.

>>> Hans Kristian Ruud <hans.kristian.ruud at inenco.no> 10/03/00 09:27AM >>>
I have generated a listbox, and wish to extract some information when a
user
  clicks on an item:

          list = Listbox(canvas,width=15 )
          list.pack(side=TOP)
          list.bind('<ButtonPress>', chooseSheet)

          def chooseSheet(event):
                  listbox = event.widget
                  selected = listbox.curselection()
                  setCurSheet( selected[0] )


  My problem is that the list of selected values from
listbox.curselection()
  is not updated until after chooseSheet is called, i.e. the function

  listbox.curselection()

  returns the PREVIOUS element that was clicked.

  Originally I had bound the function to root, and then it worked fine,
however
  I do not want the function chooseSheet to be executed when I click on
buttons
  and such that I have added later.

  Any ideas?
  Thanks in advance


--
Hans Kristian Ruud
22 18 63 08 (jobb) 22 65 22 34 (hjemme) 952 33 224 (mob)
Wash daily from nosetip to tailtip, drink deeply but not to deep
remember the night is for hunting, forget not the day is for sleep







More information about the Python-list mailing list