Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Tkinter Listbox looses selection on Tab

Reply
Thread Tools

Tkinter Listbox looses selection on Tab

 
 
=?ISO-8859-1?Q?J=F8rgen_Hansen?=
Guest
Posts: n/a
 
      07-22-2003
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()
----
 
Reply With Quote
 
 
 
 
Martin Franklin
Guest
Posts: n/a
 
      07-23-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




 
Reply With Quote
 
 
 
 
=?ISO-8859-1?Q?J=F8rgen_Cederberg?=
Guest
Posts: n/a
 
      07-24-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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Tkinter tab focus traversal causes listbox selection to clear,ie,lose the selected item Gerardo ARnaez Python 1 08-14-2008 09:09 AM
JTree Selection lost when JTree looses focus jumpz Java 3 11-12-2007 03:55 PM
Tkinter Listbox - Different Text colors in one listbox rahulnag22@yahoo.com Python 6 05-31-2007 06:48 AM
Listbox selection to populate another listbox? Chris Kettenbach ASP .Net 3 06-16-2005 09:19 PM
Re: URgent!!!!!!!!!!!! change tab selection Tab strip control Hermit Dave ASP .Net 0 01-22-2004 11:02 PM



Advertisments