Hi, I've found a way to edit the content of a ListCtrl, but I'm not able
to intercept the event when I edit something.
I've tried with EVT_LIST_END_LABEL_EDIT, but it returns *two* events
when I stop editing ...
I'd like to find a way to have the column number (or label) and the new text
(I can find the item with GetFocusedItem () I think), maybe a dict like
{ITEMID: {'name':'nicholas'}}.
I need this feature because I have to UPDATE a db when people edits a
row.
Example code in attachement.
TIA,
ngw
list.py (939 Bytes)
···
--
checking for life_signs in -lKenny... no
Oh my god, make (1) killed Kenny ! You, bastards !
nicholas_wieland-at-yahoo-dot-it
Monday, November 28, 2005, 1:59:57 PM, Nicholas Wieland wrote:
Hi, I've found a way to edit the content of a ListCtrl, but I'm not
able to intercept the event when I edit something.
To intercept the event when you're about to edit something you need to
use EVT_LIST_BEGIN_LABEL_EDIT.
I've tried with EVT_LIST_END_LABEL_EDIT, but it returns *two* events
when I stop editing ...
I just took a look at the wxPython demo and it returns only one event
here.
I'd like to find a way to have the column number (...)
The OnLeftDown method of listctrl.py, under your wx/lib/mixins
directory, does the trick.
-- tacao
No bits were harmed during the making of this e-mail.
- E. A. Tacao :
Monday, November 28, 2005, 1:59:57 PM, Nicholas Wieland wrote:
> Hi, I've found a way to edit the content of a ListCtrl, but I'm not
> able to intercept the event when I edit something.
To intercept the event when you're about to edit something you need to
use EVT_LIST_BEGIN_LABEL_EDIT.
Uhm, no, it doesn't work. I'm using the mixin, so I'm editing the whole
list, not only the label. The only event that actually works is
EVT_LIST_END_LABEL_EDIT, but as I read in textctrl.py:
# FIXME: this function is usually called twice - second time because
# it is binded to wx.EVT_KILL_FOCUS. Can it be avoided? (MW)
> I've tried with EVT_LIST_END_LABEL_EDIT, but it returns *two* events
> when I stop editing ...
I just took a look at the wxPython demo and it returns only one event
here.
I think you're looking at the example that doesn't use the mixin.
So, is there a way to edit a whole list, without calling the event twice
? I attach some example code so you can have an idea of what I'm trying
to accomplish.
Thanks for your time.
ngw
list.py (1.05 KB)
···
--
checking for life_signs in -lKenny... no
Oh my god, make (1) killed Kenny ! You, bastards !
nicholas_wieland-at-yahoo-dot-it
Tuesday, November 29, 2005, 2:53:00 PM, Nicholas Wieland wrote:
I think you're looking at the example that doesn't use the mixin.
So, is there a way to edit a whole list, without calling the event
twice ? I attach some example code so you can have an idea of what
I'm trying to accomplish. Thanks for your time.
Put this at the top of the CloseEditor method of
wx\lib\mixins\listctrl.py:
if not self.editor.IsShown():
return
And remove the 'FIXME:' comments above it. 8^)
-- tacao
No bits were harmed during the making of this e-mail.