How to make auto scrolling wx.grid table?

吃可爱长大的小学妹 提交于 2020-01-05 04:04:45

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!