Im working on a small tkinter app, in which I have a Toplevel widget
containing an entry field and a listbox, and at the bottom, there's
an "Ok" button.
What I want is to have the user put their name in the entry box,
click one of the items in the listbox, then click "Ok".
My code looks like this:
...
lb = Listbox(j)
lb.config(selectmode=SINGLE, setgrid=1)
def handleJoinClick(event, lb=lb):
index = lb.curselection()
label = lb.get(index)
sys.stderr.write("selected %s %s\n"%(repr(index), repr(label)))
lb.bind("<Button-1>", handleJoinClick)
lb.pack()
...
However, the -first- time I click -once-, the listbox claims that nothing's
been selected:
Exception in Tkinter callback
Traceback (innermost last):
File "/magnet/tools/users/davem/modules/Tkinter.py", line 551, in __call__
return apply(self.func, args)
File "GameFrame.py", line 106, in handleJoinClick
label = lb.get(index)
File "/magnet/tools/users/davem/modules/Tkinter.py", line 1223, in get
return self.tk.call(self._w, 'get', first)
But the -second- time I click -once- , it works fine:
selected ('0',) 'Gathering (1): asdf'
Can anyone shed some light on the situation for me pretty please?
yours,
dave mitchell