我知道我可以像这样使用OnPropertyChanged("CompanyName")
来获取list_ctrl.GetStringValueAt()
中特定对象的值:
ObjectListView
但是如果我想在当前循环和列索引中给出obj的字符串值更改怎么办?文档似乎没有一个方法将当前对象和列索引作为参数,所以我怎么能这样做(没有删除和重新填充元素)?
我从the docs看到有一个class myOLV(ObjectListView):
... code to handle specific events
class myPanel(wx.Panel):
def __init__(self, parent):
wx.Panel.__init__(self, parent)
self.list_ctrl = myOLV(self, wx.ID_ANY, style=wx.LC_REPORT)
self.setColumns()
# . . .
self.submit_button = wx.Button(self, label="Submit")
# ... add to sizer here, skipping tedious stuff in this example
self.submit_button.Bind(wx.EVT_BUTTON, self.onSubmit)
def setColumns(self):
self.list_ctrl.SetColumns([
ColumnDefn("Column 1", "left", 128, "col1"),
ColumnDefn("Column 2", "left", 128, "col2"),
ColumnDefn("Column 3", "left", 128, "col3")
)]
def onSubmit(self, event):
objects = self.list_ctrl.GetObjects()
for obj in objects:
col1 = self.list_ctrl.GetStringValueAt(obj, 1)
# how could I change the above value here?
col2 = self.list_ctrl.GetStringValueAt(obj, 2)
col3 = self.list_ctrl.GetStringValueAt(obj, 3)
方法,但是它设置了控件显示的modelObjects列表,这不是我想要做的。
在此上下文中是否有SetValue(modelObjects, preserveSelection=False)
方法或解决方法来执行相同的操作?