2016-01-14 20 views
0

我使用此代码更新列上的记录,但我无法更新第二和第三列。 我跟着这个link,它正在工作,但没有与我的代码。wxpython:无法更新列

 self.m_listCtrl3 = wx.ListCtrl(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LC_ALIGN_TOP|wx.LC_ICON|wx.LC_REPORT ) 
    self.m_listCtrl3.InsertColumn(0, "c1", width=-1) 
    self.m_listCtrl3.InsertColumn(1, "c2", width=-1) 
    self.m_listCtrl3.InsertColumn(2, "c3", width=-1) 
    bSizer15.Add(self.m_listCtrl3, 1, wx.ALL|wx.EXPAND, 5) 

    self.m_listCtrl3.InsertStringItem(0,"Pankaj") 
    self.m_listCtrl3.SetStringItem(0,1,"Somesh") 
    self.m_listCtrl3.SetStringItem(0,1,"Punit") 

这我得到的输出是:

enter image description here

回答

0
I got answer 
i was using wx.LC_ICON style 

self.m_listCtrl3 = wx.ListCtrl(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LC_ALIGN_TOP|wx.LC_ICON|wx.LC_REPORT ) 

but i removed that style and now code is working fine 

self.m_listCtrl3 = wx.ListCtrl(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LC_ALIGN_TOP|wx.LC_REPORT) 
0

你问它以多种格式显示。
不能同时选择wx.LC_REPORT或wx.LC_ICON。
你的目的在这里,你需要wx.LC_REPORT

另外:

self.m_listCtrl3.SetStringItem(0,1,"Punit") 

应该

self.m_listCtrl3.SetStringItem(0,2,"Punit") 
+0

由于现在是工作的罚款。但我应该怎么做,如果我想在第一列添加图标。 –

+0

查看wxPython Demo包中的代码,ListCtrl演示,它在那里 –