Tkinter Listbox looses selection on Tab

Martin Franklin mfranklin1 at gatwick.westerngeco.slb.com
Wed Jul 23 03:31:36 EDT 2003


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








More information about the Python-list mailing list