469,609 Members | 1,666 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,609 developers. It's quick & easy.

Tkinter Listbox looses selection on Tab

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)
for color in colors:
lb.insert(END, color)

lb.selection_set(0)
lb.pack()
Entry(root).pack()
root.mainloop()
----
Jul 18 '05 #1
2 5622
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


Jul 18 '05 #2
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

Jul 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Jeffrey Barish | last post: by
2 posts views Thread by Harlin Seritt | last post: by
1 post views Thread by Harlin Seritt | last post: by
1 post views Thread by Ron Provost | last post: by
3 posts views Thread by Bernard Lebel | last post: by
reply views Thread by Svenn Bjerkem | last post: by
5 posts views Thread by crystalattice | last post: by
3 posts views Thread by Kevin Walzer | last post: by
reply views Thread by devrayhaan | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.