Rich Shepard wrote:
<div class="moz-text-flowed" style="font-family: -moz-fixed"> Editing a column value in a report mode list control seems to be properly
working, but I cannot get the changed value to display. I suspect it has
something to do with the use of SetStringItem().Here is the method (with debugging print stubs):
def OnRuleEdit(self, event):
# copy contents of row for each column to var names
idx = self.rulesList.GetFirstSelected()
print 'Initial row number: ', idx
self.co = self.rulesList.GetItem(idx,0).GetText()
self.su = self.rulesList.GetItem(idx,1).GetText()
self.va = self.rulesList.GetItem(idx,2).GetText()
self.rn = self.rulesList.GetItem(idx,3).GetText()
print 'Loading values: ', self.rn
self.ru = self.rulesList.GetItem(idx,4).GetText()modRule = ruleDlg()
modRule.pName.SetValue(self.co)
modRule.sName.SetValue(self.su)
modRule.vName.SetValue(self.va)
modRule.rNum.SetValue(self.rn)
modRule.rule.SetValue(self.ru)
result = modRule.ShowModal()
if result == wx.ID_OK:
self.co = modRule.pName.GetValue()
self.su = modRule.sName.GetValue()
self.va = modRule.vName.GetValue()
self.rn = modRule.rNum.GetValue()
self.ru = modRule.rule.GetValue()
# Replace changed values
self.rulesList.InsertStringItem(idx, self.co)
print 'Row number: ', idx
self.rulesList.SetStringItem(idx, 1, self.su)
self.rulesList.SetStringItem(idx, 2, self.va)
self.rulesList.SetStringItem(idx, 3, self.rn)
print 'Writing values: ', self.rn
self.rulesList.SetStringItem(idx, 4, self.ru)
modRule.Destroy()No python errors generated when I run the application. The outputs of the
print statements are:Initial row number: 4
Loading values: WTH
Row number: 4
Writing values: WTH2However, 'WTH2' does not display; it remains 'WTH'. The code in the 'if'
loop is the same as that in the add method, so I do not understand why the
new value does not replace the original value in the displayed list control.TIA,
Rich
I suspect the issue is because of your "self.rulesList.InsertStringItem(idx, self.co)" line. I just use SetStringItem() myself. For some reason, I set the state to selected before I use the SetStringItem method...I don't recall why.
self.list_ctrl.SetItemState(cnt, wx.LIST_STATE_SELECTED, wx.LIST_STATE_SELECTED)
You can try that with or without the above.
Mike