2016-01-14 22 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演示,它在那裏 –