-
Notifications
You must be signed in to change notification settings - Fork 1
/
test_listctrl.py
executable file
·43 lines (32 loc) · 1.14 KB
/
test_listctrl.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/python
import wx
import wx.lib.mixins.listctrl as LCM
class MyApp(wx.App, LCM.ColumnSorterMixin):
def OnInit(self):
frame = wx.Frame(None, -1, "Hello from wxPython")
id=wx.NewId()
self.list=wx.ListCtrl(frame,id,style=wx.LC_REPORT|wx.SUNKEN_BORDER)
self.list.Show(True)
self.list.InsertColumn(0,"Data #1")
self.list.InsertColumn(1,"Data #2")
self.list.InsertColumn(2,"Data #3")
# 0 will insert at the start of the list
pos = self.list.InsertStringItem(0,"hello")
# add values in the other columns on the same row
self.list.SetStringItem(pos,1,"world")
self.list.SetStringItem(pos,2,"!")
pos = self.list.InsertStringItem(0,"wat")
self.list.SetStringItem(pos,1,"um")
self.list.SetStringItem(pos,2,"wha")
self.itemDataMap = {
0: ("hello","world","!"),
1: ("wat","um","wha")
}
LCM.ColumnSorterMixin.__init__(self,3)
frame.Show(True)
self.SetTopWindow(frame)
return True
def GetListCtrl(self):
return self.list
app = MyApp(0)
app.MainLoop()