如何制作自动滚动的wx.grid表格?
我在用 Python 2.7 写一个 wx.grid
表格,想知道怎么实现垂直滚动。
我试过:
MakeCellVisible(rows,cols)
还有
SetGridCursor(rows, cols)
但是都没成功。
2 个回答
0
我也遇到过同样的问题。你可以试试用 grids 函数中的 MakeCellVisible(row, col) 来解决。
1
使用:
grid_widget.Scroll(row, column)
编辑:这里有一个可以运行的例子:
这个是用以下代码生成的:
import wx
import wx.grid as grid
#
class Button(wx.Frame):
def __init__(self, parent, source):
wx.Frame.__init__(self, parent, -1, size=(100,100))
self.source = source
self.pos = 0
self.button = wx.Button(self, label='0')
self.Bind(wx.EVT_BUTTON, self.onbutton, self.button)
self.Show()
def onbutton(self, evt):
self.pos += 1
self.source.grid.Scroll(self.pos, self.pos)
self.button.SetLabel(str(self.pos))
class Frame(wx.Frame):
def __init__(self, parent):
wx.Frame.__init__(self, parent, -1, "Grid", size=(350,250))
self.grid = grid.Grid(self)
self.grid.CreateGrid(20, 20)
self.but = Button(None, self)
if __name__ == '__main__':
app = wx.PySimpleApp()
frame = Frame(None)
frame.Show()
app.MainLoop()