【问题标题】:How to make auto scrolling wx.grid table?如何使自动滚动 wx.grid 表?
【发布时间】:2011-12-29 08:45:22
【问题描述】:

python 2.7 我有wx.grid 表。如何进行垂直滚动?

我试过了:

MakeCellVisible(rows,cols) 

SetGridCursor(rows, cols)

但他们没有工作。

【问题讨论】:

    标签: python wxwidgets


    【解决方案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()
    

    【讨论】:

      【解决方案2】:

      我遇到了同样的问题。尝试使用网格函数 MakeCellVisible(row, col)

      【讨论】:

        猜你喜欢
        • 2019-12-07
        • 2021-10-29
        • 1970-01-01
        • 2020-09-08
        • 1970-01-01
        • 1970-01-01
        • 2017-03-01
        • 2016-05-29
        • 2017-11-12
        相关资源
        最近更新 更多