473,782 Members | 2,458 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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()
----
Jul 18 '05 #1
2 5829
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
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)




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
1422
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 selection in the second listbox, the selected item in the first listbox gets deselected. Is there a way to do this? I tried setting selectmode to MULTIPLE, but that option only allows me to select multiple items in one of the listboxes (both of...
2
11578
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 of the indices is selected by default?
1
1902
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() names = for n in names:
1
4335
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 need to impletement a custom selectMode. As a first go, I've attempted to implement a click-on-click-off mode. So for each entry, a click on that entry toggels its selection mode. A click on any entry does not affect the selection mode of any...
3
11281
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. Thanks Bernard
0
1426
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 then wanted to start putting some data into it. As you will see, the program is not yet finished but I post what I have so far.
5
2036
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 the selected entry. Below the Entry boxes are two buttons, one that saves the changes to the database and the other is simply a Cancel button. Under Linux, both buttons appear correctly. However, in OS X the Cancel button is invisible unless...
3
4300
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: self.fonts=list(tkFont.families()) self.fonts.sort() for item in self.fonts: self.fontlist.insert(END, item) #self.fontlist is the
1
5193
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 select if they don't like the default. I have made this as a listbox widget The rest of the gui is just entry widgets
0
9480
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10080
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9944
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7494
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6735
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5378
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4044
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3643
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2875
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.