Tkinter Listbox looses selection on Tab

Discussion in 'Python' started by =?ISO-8859-1?Q?J=F8rgen_Hansen?=, Jul 22, 2003.

  1. 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()
    ----
    =?ISO-8859-1?Q?J=F8rgen_Hansen?=, Jul 22, 2003
    #1
    1. Advertising

  2. 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
    Martin Franklin, Jul 23, 2003
    #2
    1. Advertising

  3. 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
    =?ISO-8859-1?Q?J=F8rgen_Cederberg?=, Jul 24, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Hermit Dave
    Replies:
    0
    Views:
    433
    Hermit Dave
    Jan 22, 2004
  2. Chris Kettenbach

    Listbox selection to populate another listbox?

    Chris Kettenbach, Jun 15, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    1,647
    Chris Kettenbach
    Jun 16, 2005
  3. Replies:
    6
    Views:
    596
    Hendrik van Rooyen
    May 31, 2007
  4. jumpz
    Replies:
    3
    Views:
    621
    Jean-Baptiste Nizet
    Nov 12, 2007
  5. Gerardo ARnaez
    Replies:
    1
    Views:
    711
    Eric Brunel
    Aug 14, 2008
Loading...

Share This Page