I’m refactoring a CheckListCtrl and am now getting a crash, “Segmentation fault (core dumped)”. The old code worked fine.
Old:
self.list
= CheckListCtrl(self)
self.list.InsertColumn(0, ‘Name’, width=250)
self.list.InsertColumn(1, ‘Dose’, width=180)
self.list.InsertColumn
(2, ‘Tablets’, width=60)
self.list.InsertColumn(3, ‘Frequency’, width=80)
self.list.InsertColumn(4, ‘#’, width=40)
self.list.InsertColumn
(5, ‘Refills’, width=60)
self.list.InsertColumn(6, ‘Number’, width=0)
self.list.InsertColumn(7, ‘Date’, width=100)
meds = med_find(ptID)
for i in meds:
index = self.list.InsertStringItem(sys.maxint, i[‘med_name’])
self.list.SetStringItem
(index, 1, i[‘dose’])
self.list.SetStringItem(index, 2, str(i[‘number_tablets’]))
self.list.SetStringItem(index, 3, i['frequency'])
self.list.SetStringItem(index, 4, str(i['number_pills']))
self.list.SetStringItem(index, 5, str(i['refills']))
self.list.SetStringItem(index, 6, str(i['med_number']))
self.list.SetStringItem(index, 7, str(i['script_date']))
New:
class CheckListCtrl(wx.ListCtrl, CheckListCtrlMixin, ListCtrlAutoWidthMixin):
def init(self, parent):
wx.ListCtrl.init(self, parent, -1, style=wx.LC_REPORT | wx.SUNKEN_BORDER)
CheckListCtrlMixin.init(self)
ListCtrlAutoWidthMixin.init(self)
def buildCheckListCtrl(instance, columns, data):
ctrl = CheckListCtrl(instance)
index = 0
for columnName, columnWidth in columns:
ctrl.InsertColumn
(index, columnName, width = columnWidth)
index = index + 1
for i in data:
keys = i.keys()
col = 1
newindex = ctrl.InsertStringItem(sys.maxint, i[keys[0]])
for k in keys[1:]:
ctrl.SetStringItem(newindex, col, str(i[k]))
col = col + 1
return ctrl
I would love to understand why the change is causing a problem. I am new to Python and wxPython. Unforturnately I cannot find the core dump file on the system I am using, Ubuntu 7.04. Thanks in advance for any help.
Mike