deselect an iterm in ListBox wxPython

Discussion in 'Python' started by Bailu, Aug 11, 2007.

  1. Bailu

    Bailu Guest

    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
     
    Bailu, Aug 11, 2007
    #1
    1. Advertising

  2. Bailu

    Guest

    Re: deselect an iterm in ListBox wxPython

    On Aug 11, 2:53 am, Bailu <> wrote:
    > 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, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Logan McKinley

    deselect calendar control

    Logan McKinley, Jun 2, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    496
    =?Utf-8?B?WS5Bcmdvbg==?=
    Jun 24, 2004
  2. Amit Kohli

    Deselect rows in a grid

    Amit Kohli, Jul 8, 2003, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    121
    Alvin Bruney
    Jul 9, 2003
  3. rpress

    How to deselect item on single select listbox?

    rpress, Jan 3, 2006, in forum: ASP .Net Web Controls
    Replies:
    5
    Views:
    1,480
    rpress
    Jan 9, 2006
  4. Matt Mower

    iTerm and Ruby::OSA

    Matt Mower, Oct 28, 2007, in forum: Ruby
    Replies:
    3
    Views:
    108
  5. Replies:
    10
    Views:
    244
Loading...

Share This Page