Binding Enable(True/False) for several widgets with wx.EVT_LIST_ITEM_SELECTED/DESELECTED in ListCtrl

Dear wxPythoners,

I’ve been developing some kind of text-file editor.

It is composed of two parts;
the labels and textctrls in the upper part for inputting
and a listctrl in the lower part for outputting.

I want to switch enable/disable for labels and textctrls
depeding on the status of selection the item in the listctrl.

The attached is my example script.
It seems to be achived my wish. However, there is a problem.

The problem is that it always call the “lostFocusedItem” method
whenever another item is selected by clocking left button,
or pressing the Up/Down cursors. Then, a window flickers.
In such cases, I don’t need disable the labels and textctrls
because they will be enabled the next moment
by the “getFocusedItem” method

with a wx.EVT_LIST_ITEM_SELECTED event.

Do you have any suggestions?

Thank you in advance.

PS I know that wx.lib.mixins.listctrl.TextEditMixin makes it
possible to edit items in the listctrl. But I want to separately
prepare widgets for inputting (TextCtrl) and outputting (ListCtrl).

All the best,
Masami

test.py (1.97 KB)

I’m not sure I understand your desires here, but that is the nature of the selected events and the behavior of the widget. When a new item is selected the old one is deselected first. If you don’t want to disable them when an item is deselected then don’t do it in that event handler. Maybe there is a better time to do it? Maybe, but I can’t really say without understanding how you want it to work.

···

On Wednesday, October 31, 2018 at 7:25:01 AM UTC-7, Masa wrote:

The problem is that it always call the “lostFocusedItem” method

whenever another item is selected by clocking left button,
or pressing the Up/Down cursors. Then, a window flickers.
In such cases, I don’t need disable the labels and textctrls
because they will be enabled the next moment
by the “getFocusedItem” method

with a wx.EVT_LIST_ITEM_SELECTED event.

Robin