效果图:
示例代码:
[python] view plaincopy
- #! /usr/bin/env python
- #coding=utf-8
- import wx
- import sys
- packages = [(‘jessica alba‘, ‘pomona‘, ‘1981‘), (‘sigourney weaver‘, ‘new york‘, ‘1949‘),
- (‘angelina jolie‘, ‘los angeles‘, ‘1975‘), (‘natalie portman‘, ‘jerusalem‘, ‘1981‘),
- (‘rachel weiss‘, ‘london‘, ‘1971‘), (‘scarlett johansson‘, ‘new york‘, ‘1984‘ )]
- class MyFrame(wx.Frame):
- def __init__(self, parent, id, title, size):
- wx.Frame.__init__(self, parent, id, title, size)
- hbox = wx.BoxSizer(wx.HORIZONTAL)
- panel = wx.Panel(self, -1)
- self.list = wx.ListCtrl(panel, -1, style=wx.LC_REPORT)
- self.list.InsertColumn(0, ‘name‘, width=140)
- self.list.InsertColumn(1, ‘place‘, width=130)
- self.list.InsertColumn(2, ‘year‘, wx.LIST_FORMAT_RIGHT, 90)
- for i in packages:
- index = self.list.InsertStringItem(sys.maxint, i[0])
- self.list.SetStringItem(index, 1, i[1])
- self.list.SetStringItem(index, 2, i[2])
- hbox.Add(self.list, 1, wx.EXPAND)
- panel.SetSizer(hbox)
- self.Centre()
- class MyApp(wx.App):
- def OnInit(self):
- frame = MyFrame(None, id=-1, title="DownThemAll", size=(800,600))
- frame.Show(True)
- self.SetTopWindow(frame)
- return True
- if __name__ == ‘__main__‘:
- app = MyApp()
- app.MainLoop()
时间: 2024-10-28 14:39:59