Tkinter Listbox looses selection on Tab

Jørgen Cederberg jorgencederberg at hotmail.com
Thu Jul 24 08:58:53 CEST 2003


Martin Franklin wrote:
> On Tuesday 22 July 2003 19:40, Jørgen Hansen wrote:
> 
>>Hi
>>
>>I have a problem with a Listbox in Tkinter. When I tab through several
>>widgets with the tab-key, the listbox looses its selection, even
>>though it has been selected with .selection_set. The example below
>>demonstrates this. Can anyone provide me with some help on this?
>>
>>Regards
>>Jorgen
>>
>>Ps. I'm on a W2K machine with Python 2.2.2
>>
>>----
>>from Tkinter import *
>>
>>root = Tk()
>>colors = ['Yellow', 'Black', 'White', 'Green']
>>
>>lb = Listbox(root)
> 
> 
> 
> Jorgen,
> 
> Try setting exportselection=0 in the Listbox construction like so:
> 
> lb = Listbox(root, exportselection=0)
> 
> This seems to work on my linux box.
> 
> 
> Martin
> 
> 

Hi Martin,

It worked on my W2K machine too! Thanks alot. I skimmed through some 
TCL/TK documentation, but I'm still somewhat puzzled over the default 
behavior.

But I'm sure I'll figure it out someday.

Have a nice day
Jorgen





More information about the Python-list mailing list