Tkinter Listbox looses selection on Tab

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jørgen Hansen

    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_se t(0)
    lb.pack()
    Entry(root).pac k()
    root.mainloop()
    ----
  • Martin Franklin

    #2
    Re: Tkinter Listbox looses selection on Tab

    On Tuesday 22 July 2003 19:40, Jørgen Hansen wrote:[color=blue]
    > 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)[/color]


    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




    Comment

    • Jørgen Cederberg

      #3
      Re: Tkinter Listbox looses selection on Tab

      Martin Franklin wrote:[color=blue]
      > On Tuesday 22 July 2003 19:40, Jørgen Hansen wrote:
      > [color=green]
      >>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
      >>demonstrate s 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)[/color]
      >
      >
      >
      > 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
      >
      > [/color]

      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

      Comment

      Working...