我必须得到一个只有两个字符串列的列表。在 GTK 上一切正常,但在 Windows 7 上我得到了这个:
class ListViewCtrl(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin):
def __init__(self, parent, ID, pos=wx.DefaultPosition, size=wx.DefaultSize, style=0):
wx.ListCtrl.__init__(self, parent, ID, pos, size, style)
listmix.ListCtrlAutoWidthMixin.__init__(self)
class ListView(wx.Panel, listmix.ColumnSorterMixin):
def __init__(self, parent):
wx.Panel.__init__(self, parent, -1, style=wx.WANTS_CHARS)
self.il = wx.ImageList(16, 16)
self.up = self.il.Add(resources.filter_up.GetBitmap())
self.dn = self.il.Add(resources.filter_down.GetBitmap())
self.list = ListViewCtrl(self, -1, style=wx.LC_REPORT | wx.SIMPLE_BORDER | wx.LC_EDIT_LABELS | wx.LC_SORT_ASCENDING)
self.list.SetImageList(self.il, wx.IMAGE_LIST_SMALL)
i = 0
_program_dir = os.path.split(__file__)[0]
self.itemDataMap = {}
for fn in os.listdir(os.path.join(_program_dir, '../design/caps')):
self.itemDataMap[i] = (fn, "Line {0}".format(i+1))
i += 1
self.PopulateList()
listmix.ColumnSorterMixin.__init__(self, 3)
self.__DoLayout()
def __DoLayout(self):
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(self.list, 1, wx.EXPAND)
self.SetSizer(sizer)
self.SetAutoLayout(True)
def PopulateList(self):
info = wx.ListItem()
info.m_mask = wx.LIST_MASK_TEXT | wx.LIST_MASK_IMAGE | wx.LIST_MASK_FORMAT
info.m_image = -1
info.m_format = 0
info.m_text = "File name"
self.list.InsertColumnInfo(0, info)
info.m_text = "Column 2"
self.list.InsertColumnInfo(1, info)
for k, v in self.itemDataMap.items():
index = self.list.InsertStringItem(sys.maxint, v[0])
self.list.SetStringItem(index, 1, v[1])
self.list.SetItemData(index, k)
self.list.SetColumnWidth(0, 100)
self.list.SetColumnWidth(1, wx.LIST_AUTOSIZE)
self.currentItem = 0
def GetListCtrl(self):
return self.list
def GetSortImages(self):
return (self.dn, self.up)
每行使用附件图像列表中的图像编号 0。我怎样才能摆脱这个图标?
wxPython 2.9.2.4,Win7 x64
更新:
这是来自 GTK 的列表(没有您看到的图标):