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
|
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
import wx
class MyFrame(wx.Frame):
def __init__(self, parent, id, title):
wx.Frame.__init__(self, parent, id, title, wx.DefaultPosition)
self.lc = wx.ListCtrl(self, -1, style=wx.LC_REPORT, size=(-1,-1))
self.lc.InsertColumn(0, 'Toto')
self.lc.InsertColumn(1, 'Tata')
self.lc.InsertColumn(2, 'Titi')
self.lc.InsertStringItem(0, "Toto Un")
self.lc.SetStringItem(0,1,"Tata Un")
self.lc.SetStringItem(0,2,"Titi Un")
self.lc.InsertStringItem(0, "Toto Deux")
self.lc.SetStringItem(0,1,"Tata Deux")
self.lc.SetStringItem(0,2,"Titi Deux")
self.Bind(wx.EVT_PAINT, self.OnPaint)
def OnPaint(self, evt):
larg, haut = self.lc.GetSize()
for i in range(3):
self.lc.SetColumnWidth(i, larg/3)
evt.Skip()
class MyApp(wx.App):
def OnInit(self):
frame = MyFrame(None, -1, "Liste")
frame.Show(True)
self.SetTopWindow(frame)
return True
app = MyApp(0)
app.MainLoop() |
Partager