首先需要定义类似数据模板的类。

import wx.grid as grid

class MyDataTable(grid.PyGridTableBase):
    def __init__(self,data,colLabels=None):
        grid.PyGridTableBase.__init__(self)
        self.colLabels = colLabels
        self.data = data

    def GetNumberRows(self):
        return len(self.data)

    def GetNumberCols(self):
        return len(self.data[0])

    def GetValue(self,row,col):
        if self.data[row][col] is None:
            return ''
        else:
            return self.data[row][col]

    def SetValue(self,row,col,value):
        pass

    def GetColLabelValue(self,col):
        if self.colLabels:
            return self.colLabels[col]

调用设置表格显示。

class ShowData:
    @classmethod
    def showSqlData(self,data,grid):
        table = MyDataTable(data[1],data[0])
        grid.SetTable(table)
        grid.AutoSize()
        grid.Refresh()

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-09
  • 2021-11-30
  • 2021-11-08
  • 2021-06-13
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-10-15
  • 2021-09-07
  • 2021-12-18
  • 2021-08-30
  • 2022-12-23
相关资源
相似解决方案