EditableListBox selection of item does not trigger a EVT_LIST_ITEM_SELECTED

EditableListBox selection of item does not trigger a EVT_LIST_ITEM_SELECTED

Dear all,
In my simple app I have an editablelistbox in a panel in a frame.
I have two bind method: one for when the user clicks on the new button and one for when the user selects an item of the list.
The bind to the new item selction works while the one on the item selction does not work.
I use wx.EVT_LIST_INSERT_ITEM for the click on new item button and wx.EVT_LIST_ITEM_SELECTED for the item selection.
I attach the very simple test I made up to show the issue.
Best regards,
Andrea
using python 3.7.9 wx 4.1.1 but also 4.2.0

test2.py (1.2 KB)

self.editbox.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OnSelect)

Works for me using Python 3.10.6 + wxPython 4.2.0 gtk3 (phoenix) wxWidgets 3.2.0 + Linux Mint 21.1.

However, you then need to call event.Skip() in the OnSelect() method so that the normal behaviour of the EditableListBox still happens.

Dear Richard,
thank you for your answer, I will update to py 3.10.
Andrea

Hi Andrea,

Please note that it’s calling the editbox’s Bind() method directly, instead of calling the Frame’s Bind() method that makes this work, rather than the use of py 3.10.

There is a good discussion of this subject in the wiki:

https://wiki.wxpython.org/self.Bind%20vs.%20self.button.Bind

Dear Richard,
thank you again for your help.
Unfortunately in my pc if I Bind to the editbox, when I select the new item button, the OnSelect gets triggered, which is not what I want (I would like to trigger the OnNew on new item insert and the OnSelec on the item selection).
The strange thing is that If I choose to use the wx.EVT_LIST_ITEM_ACTIVATED(which requires a double left click on the item), it correclty triggers the OnSelect as expected.
I attach the modified script for clarity.
Andrea
test2.py (1.2 KB)

How about ignoring blank text selections?

    def OnSelect(self, event):
        if event.Text:
            print('OnSelect', event.Text)
        event.Skip()

Dear @komoto48g ,
thank you I will consider it.
Thanks,
Andrea