473,394 Members | 1,567 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

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 5807
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Jeffrey Barish | last post by:
I have an application that produces two listboxes. I would like to be able to select one of the items in the first listbox and one of the items in the second listbox. However, when I make my...
2
by: Harlin Seritt | last post by:
Whenever I set up something similar: vals = for v in vals: listbox.inset(END, v) I notice that when this listbox is displayed, there is never a default value. How can I make sure that one...
1
by: Harlin Seritt | last post by:
I am trying to poll selections from a listbox but can't seem to get it to work correctly. class pollstuff: def __init__(self, master): self.listbox = Listbox(master) self.listbox.pack() ...
1
by: Ron Provost | last post by:
Hello, I've written a simple GUI which contains a listbox to hold some information. I've found that the click-selection schemes provided by Tkinter are insufficient for my needs. Essentiall I...
3
by: Bernard Lebel | last post by:
Hello, Is there an option or a way to allow the selection of multiple entries in the Listbox widget? I could not find any, and would like to allow the end user to select multiple entries. ...
0
by: Svenn Bjerkem | last post by:
Hi, Armed with Programming Python 3rd Edition and Learning Python 2nd edition I try to write an application which I at first thought was simple, at least until I was finished with the GUI and...
5
by: crystalattice | last post by:
I'm creating a shelve interface using Tkinter. I have a button that allows the user to modify an existing entry; when the button is clicked, a new TopLevel window appears with Entry boxes holding...
3
by: Kevin Walzer | last post by:
I'm trying to set the active item in a Tkinter listbox to my application's currently-defined default font. Here's how I get the fonts loaded into the listbox: ...
1
by: Gerardo ARnaez | last post by:
Hi. I am writing a program to help determine coumadin regimens to look at the code: http://sourceforge.net/projects/coumadinregimen/ The issue is that I have a variable that I want the use to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.