user1000571
user1000571

Reputation: 25

How to make auto scrolling wx.grid table?

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.

Upvotes: 1

Views: 4067

Answers (2)

I had the same problem. Just try to use grids function MakeCellVisible(row, col)

Upvotes: 0

joaquin
joaquin

Reputation: 85603

Use:

grid_widget.Scroll(row, column)

Edit: Here you have a working example:

enter image description here

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()

Upvotes: 1

Related Questions