概述
#-*- 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 ( )
最后
以上就是飞快跳跳糖为你收集整理的Python 表格的MVC 模式的全部内容,希望文章能够帮你解决Python 表格的MVC 模式所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复