473,574 Members | 3,125 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

deselect an iterm in ListBox wxPython

Hi,

I am a newbie in wxPython and doing a program with ListBox,
I want to select and deselect items in this box,
I have use

self.devlist = wx.ListBox(self , style=wx.LB_MUL TIPLE)
self.Bind(wx.EV T_LISTBOX, self.select_dev , self.devlist)

to create this box, but don't know how to implement self.select_dev
to find out which one is clicked

deselect it, if it was selected ( this is not working at default)
select it, if it was not (toggle)

The default behavior is, the selection is increasing, I can't deselect
any of them.

Thanks.

Lingyun

Aug 11 '07 #1
1 4578
On Aug 11, 2:53 am, Bailu <lingyun.y...@g mail.comwrote:
Hi,

I am a newbie in wxPython and doing a program with ListBox,
I want to select and deselect items in this box,
I have use

self.devlist = wx.ListBox(self , style=wx.LB_MUL TIPLE)
self.Bind(wx.EV T_LISTBOX, self.select_dev , self.devlist)

to create this box, but don't know how to implement self.select_dev
to find out which one is clicked

deselect it, if it was selected ( this is not working at default)
select it, if it was not (toggle)

The default behavior is, the selection is increasing, I can't deselect
any of them.

Thanks.

Lingyun
You should look at the wxPython demo's code for the wx.ListBox. It
looks like they use the wx.EVT_LISTBOX event. See below:

<code>
# this writes to a multiline TextCtrl
self.log.WriteT ext('EvtListBox : %s, %s, %s, %s\n' %
(event.GetStrin g(),
event.IsSelecti on(),
event.GetSelect ion(),
event.GetClient Data()))
</code>

I'm not sure, but I think it uses the SetSelection() method to select
an item, which seems to deselect the previously selected item...at
least, that's how I interpret the demo.

The demo is here: http://wxpython.org/download.php

If you need additional help, try posting to the wxPython User's group:
http://wxpython.org/maillist.php

Regards,

Mike

Aug 11 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
10600
by: Andrew | last post by:
Hi I just started learning wxPython I wanted to know how I could do this in wxPython self.listbox.delete(0, END) for item in self.results: self.listbox.insert(END, item)
4
7140
by: GJP | last post by:
Hello. I have two list boxes. One with a picture name, and one for the ID of that picture (both coming from a database). The user selects the name of the picture and presses a button, the picture and the picture ID are then moved to other list boxes. This works ok, but once this has been done, i dont want to delete the item from the...
4
2349
by: Bill Nguyen | last post by:
I would like to be able to do the following: Listbox1/Textbox1 contains list of all items not selected item A item B item D Listbox2//Textbox2 contains list of all items selected
7
13621
by: deepagulati | last post by:
Hi, I need an urgent help from you. When we dynamically genrate any list box (Select Box) it shows one default value as selected. Is there any way that we can deselect that value. I tried with document.form_Name.ListBox_Name.options.selected =
1
6527
by: dev.amit | last post by:
Hello friends Can anyone tell me how to deselect the item selected in the list box If Me!lb_test_property.ItemsSelected.Count > 0 Then For Each varItem In Me!lb_test_property.ItemsSelected Me!lb_test_property.ItemsSelected = ######## Next varItem End If i want to know the code for the ### marked area Thanks in advance
6
6206
by: shuf | last post by:
Hello, I am running python 2.4.4 with wxpython 2.6 on Fedora 6. I am trying to set the font color of individual elements in a listbox, but I am not able to with SetItemForegroundColour() (this method does not appear to do anything): #!/usr/bin/env python # -*- coding: UTF-8 -*- # generated by wxGlade 0.4.1 on Thu Mar 22 12:15:29 2007...
6
19970
by: rahulnag22 | last post by:
Hi, Is it possible to have different items in a listbox in different colors? Or is it just one color for all items in a listbox? Thanks Rahul
1
1523
by: Marcpp | last post by:
Hi, I need add to a listbox a list of items extracted from a database. This is that I've do: class tasques(wx.Frame): def __init__(self, *args, **kwds): ..... self.list_box_1_copy = wx.ListBox(self, -1, choices=, style=wx.LB_SINGLE|wx.LB_ALWAYS_SB) ....
3
2301
by: Soren | last post by:
Hi, Id like to make my own special listbox.. I want to able (at the push of a button) to add another item to my special listbox... each item is a panel with a label, some buttons and maybe a text control. I've tried adding a new panel object with the stuff i want to the sizer i'm using for my listbox (which is a panel which can contain...
0
7805
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8052
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8234
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7815
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...
1
5620
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...
0
3749
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2243
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
1
1339
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1060
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...

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.