任何帮助都表示赞赏这让我疯了
import wx
class Frame(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None, -1)
# dp = DownloadPanel(self)
# dl = dp.download_list
dl = wx.ListCtrl(self, -1, style=wx.LC_REPORT)
dl.InsertColumn(0, "File")
dl.InsertColumn(1, "Progress")
dl.InsertColumn(2, "State")
dl.SetStringItem(0, 0, "FILE")
dl.SetStringItem(0, 1, "PERCENT")
dl.SetStringItem(0, 2, "STATE")
dl.SetStringItem(1, 0, "FILE")
dl.SetStringItem(1, 1, "PERCENT")
dl.SetStringItem(1, 2, "STATE")
dl.SetStringItem(2, 0, "FILE")
dl.SetStringItem(2, 1, "PERCENT")
dl.SetStringItem(2, 2, "STATE")
dl.SetStringItem(3, 0, "FILE")
dl.SetStringItem(3, 1, "PERCENT")
dl.SetStringItem(3, 2, "STATE")
self.Refresh()
dl.Refresh()
self.Update()
dl.Update()
self.Layout()
dl.Layout()
if __name__ == "__main__":
a = wx.App(False)
f = Frame()
f.Show()
a.MainLoop()
好的,当我运行这个项目没有显示时,我做错了什么?我正在添加这些项目。 AHHHH!
答案 0 :(得分:3)
使用InsertStringItem
开始新行:
import wx
import sys
class Frame(wx.Frame):
def __init__(self, parent):
wx.Frame.__init__(self, parent, size=(380, 230))
dl = wx.ListCtrl(self, -1, style=wx.LC_REPORT)
dl.InsertColumn(0, 'File')
dl.InsertColumn(1, 'Progress')
dl.InsertColumn(2, 'State')
for row in range(3):
labels = [l+str(row) for l in "FILE PERCENT STATE".split()]
# sys.maxint inserts at the end of the list
index = dl.InsertStringItem(sys.maxint, labels[0])
dl.SetStringItem(index, 1, labels[1])
dl.SetStringItem(index, 2, labels[2])
self.Show(True)
app = wx.App()
Frame(None)
app.MainLoop()
产量