By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
439,985 Members | 1,574 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 439,985 IT Pros & Developers. It's quick & easy.

deselect an iterm in ListBox wxPython

P: n/a
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_MULTIPLE)
self.Bind(wx.EVT_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
Share this Question
Share on Google+
1 Reply


P: n/a
On Aug 11, 2:53 am, Bailu <lingyun.y...@gmail.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_MULTIPLE)
self.Bind(wx.EVT_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.WriteText('EvtListBox: %s, %s, %s, %s\n' %
(event.GetString(),
event.IsSelection(),
event.GetSelection(),
event.GetClientData()))
</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 discussion thread is closed

Replies have been disabled for this discussion.