主要是一些资料的汇总:
#!/usr/bin/python
#-*- coding:utf8 -*-
import wx
import wx.grid as grid
class EventTable(grid.PyGridTableBase):
def __init__(self):
grid.PyGridTableBase.__init__(self)
self.odd = grid.GridCellAttr()
self.odd.SetBackgroundColour("yellow")
self.even = grid.GridCellAttr()
def GetAttr(self, row, col, kind):
attr = [self.even, self.odd][row % 2]
attr.IncRef()
return attr
def GetNumberRows(self):
return 8
def GetNumberCols(self):
return 8
def GetValue(self, row, col):
return str(col)
def SetValue(self, row, col, value):
print (row, col, value)
class Frame(wx.Frame):
def __init__(self, root):
wx.Frame.__init__(self, root, -1, u"表格", size=(450,250))
gridTest = grid.Grid(self)
table = EventTable()
gridTest.SetTable(table, True)
class MyApp(wx.App):
def OnInit(self):
self.frame = Frame(None)
self.frame.Show()
return True
app = MyApp()
app.MainLoop()
示例2:
#!/usr/bin/python
#-*- coding:utf8 -*-
import wx
import wx.grid
class GridFrame