问题
python 2.7 I have wx.grid
table. How can I do vertical scrolling?
I tried:
MakeCellVisible(rows,cols)
and
SetGridCursor(rows, cols)
but they didn't work.
回答1:
Use:
grid_widget.Scroll(row, column)
Edit: Here you have a working example:
That was produced with:
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()
回答2:
I had the same problem. Just try to use grids function MakeCellVisible(row, col)
来源:https://stackoverflow.com/questions/8665633/how-to-make-auto-scrolling-wx-grid-table