#-*- coding:utf8 -*-
import wx
import wx.grid
class GeneralTable(wx.grid.PyGridTableBase):
def __init__(self,data,rowLabels=None, colLabels=None):
wx.grid.PyGridTableBase.__init__(self)
self.data = data
self.rowLabels = rowLabels
self.colLabels =colLabels
def GetNumberRows(self):
return len(self.data)
def GetNumberCols(self):
return len(self.data[0])
def GetColLabelValue(self,col):
if self.colLabels:
return self.colLabels[col]
def GetRowLabelValue(self,row):
if self.rowLabels:
return self.rowLabels[row]
def IsEmptyCell(self,row,col):
return False
def GetValue(self,row,col):
return self.data[row][col]
def SetValue(self,row,col,value):
pass
# -*- coding:utf8 -*-
__author = 'shencheng'
import wx.grid
import wx
import generaltable
data = ((u"张三" , u"李四" , u"王五" , u"赵六") ,
(u"张三" , u"李四" , u"王五" , u"赵六") ,
(u"张三" , u"李四" , u"王五" , u"赵六") ,
(u"张三" , u"李四" , u"王五" , u"赵六") ,
(u"张三" , u"李四" , u"王五" , u"赵六") ,
(u"张三" , u"李四" , u"王五" , u"赵六") ,
(u"张三" , u"李四" , u"王五" , u"赵六") ,
(u"张三" , u"李四" , u"王五" , u"赵六") ,
(u"张三" , u"李四" , u"王五" , u"赵六") ,)
rowLabels = ("Last " , "First" , "Second" , "Third")
colLabels = ("CF" , "2B" , "LF" , "1B" , "RF" , "3B" , "C" , "SS" , "P")
class MyGrid ( wx.grid.Grid ):
def __init__(self , parent):
wx.grid.Grid.__init__ ( self , parent )
tableBase = generaltable.GeneralTable ( data , colLabels , rowLabels )
self.SetTable ( tableBase )
class MyFrame ( wx.Frame ):
def __init__(self , parent):
wx.Frame.__init__ ( self , parent , -1 , "A Grid" ,
size=(300 , 300) )
grid = MyGrid ( self )
if __name__ == '__main__':
app = wx.PySimpleApp ( )
frame = MyFrame ( None )
frame.Show ( )
app.MainLoop ( )
import wx
import wx.grid
class GeneralTable(wx.grid.PyGridTableBase):
def __init__(self,data,rowLabels=None, colLabels=None):
wx.grid.PyGridTableBase.__init__(self)
self.data = data
self.rowLabels = rowLabels
self.colLabels =colLabels
def GetNumberRows(self):
return len(self.data)
def GetNumberCols(self):
return len(self.data[0])
def GetColLabelValue(self,col):
if self.colLabels:
return self.colLabels[col]
def GetRowLabelValue(self,row):
if self.rowLabels:
return self.rowLabels[row]
def IsEmptyCell(self,row,col):
return False
def GetValue(self,row,col):
return self.data[row][col]
def SetValue(self,row,col,value):
pass
# -*- coding:utf8 -*-
__author = 'shencheng'
import wx.grid
import wx
import generaltable
data = ((u"张三" , u"李四" , u"王五" , u"赵六") ,
(u"张三" , u"李四" , u"王五" , u"赵六") ,
(u"张三" , u"李四" , u"王五" , u"赵六") ,
(u"张三" , u"李四" , u"王五" , u"赵六") ,
(u"张三" , u"李四" , u"王五" , u"赵六") ,
(u"张三" , u"李四" , u"王五" , u"赵六") ,
(u"张三" , u"李四" , u"王五" , u"赵六") ,
(u"张三" , u"李四" , u"王五" , u"赵六") ,
(u"张三" , u"李四" , u"王五" , u"赵六") ,)
rowLabels = ("Last " , "First" , "Second" , "Third")
colLabels = ("CF" , "2B" , "LF" , "1B" , "RF" , "3B" , "C" , "SS" , "P")
class MyGrid ( wx.grid.Grid ):
def __init__(self , parent):
wx.grid.Grid.__init__ ( self , parent )
tableBase = generaltable.GeneralTable ( data , colLabels , rowLabels )
self.SetTable ( tableBase )
class MyFrame ( wx.Frame ):
def __init__(self , parent):
wx.Frame.__init__ ( self , parent , -1 , "A Grid" ,
size=(300 , 300) )
grid = MyGrid ( self )
if __name__ == '__main__':
app = wx.PySimpleApp ( )
frame = MyFrame ( None )
frame.Show ( )
app.MainLoop ( )