import wx
import wx.grid
import pandas as pd
class GridTable(wx.grid.Grid):
def __init__(self, parent, nrow=30, ncol=20):
wx.grid.Grid.__init__(self, parent)
#默认30行20列
self.CreateGrid(nrow, ncol)
#自动行数
def AutoRowNums(self, cur_rows=0, to_rows=0):
if cur_rows < to_rows:
self.InsertRows(to_rows, to_rows - cur_rows, updateLabels=True)
elif cur_rows > to_rows:
self.DeleteRows(to_rows, cur_rows - to_rows, updateLabels=True)
else:
pass
#自动列数
def AutoColNums(self, cur_cols=0, to_cols=0):
if cur_cols < to_cols:
self.InsertCols(cur_cols, to_cols - cur_cols, updateLabels=True)
elif cur_cols > to_cols:
self.DeleteCols(to_cols, cur_cols - to_cols, updateLabels=True)
else:
pass
#删除所有行
def DeleteAllRows(self):
if self.GetNum
用wxpython的Grid展示dataframe表格
于 2023-11-19 19:42:10 首次发布