debug.py (6.3 KB)
Hi all,
I have two DataViewCtrl work fine with PyDataViewModel. (in wxpython 4.0.6)
What I want to do is moving some items from one control to another and then select them.
As the codes below, however, the call of self.dvc2.SetSelections(to_select) always make my program crashed.
Is it correct to use DataViewItemArray like this way? Any help would be much appreciated.
def on_btn_auto_classify(self, event):
mod1 = self.mod1
mod2 = self.mod2
to_select = dv.DataViewItemArray()
undecided_grp = mod1.data['undecided']
for obj in list(undecided_grp.children):
undecided_grp.children.remove(obj)
rand_grp = mod2.data[f'group{random.randint(1, 3)}']
rand_grp.add_child(obj)
to_select.append(mod2.ObjectToItem(obj))
mod1.Cleared()
mod2.Cleared()
self.dvc2.SetFocus()
self.dvc2.UnselectAll()
#self.dvc2.SetSelections(to_select) # crashed