I am new to wxPython and am trying to add a DataViewTreeControl. The control shows up just fine. However, when I associate data I get Segmentation fault (core dumped)
. I have done enough work to know that it happens every time when it is trying to return from the GetValue()
method.
I have patterned my implementation after the Data View Model Demo and I believe that it is done properly.
I have read that incorrectly trying to update objects can cause this kind of error (here) but I do not believe I am doing this. I have attempted using wx.CallAfter()
and wx.CallLater()
without luck.
The application does have a toolbar and grid currently working so I know the whole thing isn't broken.
If I leave the implementation as in the demo above the segmentation fault occurs when attempting the return mapper[col]
(equivalent to line 180 in the demo) in this case the type of mapper[col]
is 'unicode'
.
If I convert the value to string (this is what my column data type is set to be) then I get further before the seg fault occurs on line 16 below (I am not sure if this is important or not, but here it is):
> /usr/lib/python2.7/encodings/utf_8.py(16)decode()
15 def decode(input, errors='strict'):
---> 16 return codecs.utf_8_decode(input, errors, True)
I am looking for some direction regarding whether this is likely a threading issue or if it might be an error with my implementation of the data model.
As I said this works until I try to associate a model with the control. Here is a minimum non-working example (self, in this case is the wx.Frame) :
def get_metadata(self):
mdDict = dict()
a1 = coremetadata.mdCoreAttribute(0, 'att1', 'cat1', 1, 'core1')
a2 = coremetadata.mdCoreAttribute(1, 'att2', 'cat1', 2, 'core1')
a3 = coremetadata.mdCoreAttribute(2, 'att3', 'cat3', 3, 'core1')
c1 = coremetadata.mdCore('core1')
c1.atts.append(a1)
c1.atts.append(a2)
c1.atts.append(a3)
mdDict['core1'] = c1
return coremetadata.CoreMetaData(mdDict.values())
def createDVTC(self):
self.dvtc = dv.DataViewTreeCtrl(self.grid, wx.ID_ANY, size=(300,300))
mdata = self.get_metadata()
# tell the object to use our data
self.dvtc.AssociateModel(mdata)
return self.dvtc
def create_mdPane(self):
self.dvtc = self.createDVTC()
self._mgr.AddPane(self.dvtc, aui.AuiPaneInfo().
Name("MDNotebook").Caption("Metadata Display").
Right().Layer(1).Position(1).MinimizeButton(True))
Thanks for any help!