我是靠谱客的博主 飞快跳跳糖,这篇文章主要介绍Python 表格的MVC 模式,现在分享给大家,希望可以做个参考。

#-*- 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内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(40)

评论列表共有 0 条评论

立即
投稿
返回
顶部