How to get scrollbar object of grid window?

When the grid window is too small, the grid automatically displays a vertical/horizontal scrollbar.Where as, there is aScrollBar object, which has GetThumbPosition() method to get the positon of the scrollbar.

How do I apply this GetThumbPosition() method to this automatically created scrollbar in grid? Do I have to get the scrollbar object of the grid first? I want to get the scrollbar position (int)

Best Regards

What would you do with that information? You wouldn’t have any idea
what the units are. The grid window is managing that scroll bar.
Only it knows how to map the scroll bar’s raw position information
into rows and columns, and that mapping is not exposed to you.
Now you can usually ask the grid to tell you what the topmost
visible row and leftmost visible column are. Is that enough?

···

steve wrote:

    When the grid window is too small, the grid

automatically displays a vertical/horizontal scrollbar. Where as, there
is a ScrollBar object, which has GetThumbPosition()
method to get the positon of the scrollbar.

    How do I apply this `GetThumbPosition()` method to

this automatically created scrollbar in grid? Do I have to get
the scrollbar object of the grid first? I want to get the
scrollbar position (int)

-- Tim Roberts, Providenza & Boekelheide, Inc.

timr@probo.com

Maybe. I have 2 grids side by side. I want to scroll them synchronously, that’s why I need the position of the scrolls.

The following class helps me with what I want, but it works only when you drag with any of the scrollbars with mouseclick. It won’t work when you use the mousewheel. I tried creating a copy of this class using wx.EVT_MOUSEWHEEL event instead of wx.EVT_SCROLLWIN. However wx.EVT_MOUSEWHEEL event doesn’t have a “Position” property. Therefore I’d like to get the position of the first grid’s scroll, then pass it to the mousewheel class.

class NewScrollSync(object):
def init(self, panel1, panel2):
self.panel1 = panel1
self.panel2 = panel2
self.panel1.grid.Bind(wx.EVT_SCROLLWIN, self.onScrollWin1)
self.panel2.grid.Bind(wx.EVT_SCROLLWIN, self.onScrollWin2)

def onScrollWin1(self, event):

        if event.Orientation == wx.SB_HORIZONTAL:
            self.panel2.grid.Scroll(event.Position, -1)
        else:
            self.panel2.grid.Scroll(-1, event.Position)

        event.Skip()

def onScrollWin2(self, event):

        if event.Orientation == wx.SB_HORIZONTAL:
            self.panel1.grid.Scroll(event.Position, -1)
        else:
            self.panel1.grid.Scroll(-1, event.Position)

        event.Skip()

source for the class above: http://www.blog.pythonlibrary.org/2013/12/17/wxpython-201-syncing-scrolling-two-grid/

···

On Saturday, January 3, 2015 1:00:23 AM UTC+2, Tim Roberts wrote:

steve wrote:

    When the grid window is too small, the grid

automatically displays a vertical/horizontal scrollbar. Where as, there
is a ScrollBar object, which has GetThumbPosition()
method to get the positon of the scrollbar.

    How do I apply this `GetThumbPosition()` method to

this automatically created scrollbar in grid? Do I have to get
the scrollbar object of the grid first? I want to get the
scrollbar position (int)

What would you do with that information?  You wouldn't have any idea

what the units are. The grid window is managing that scroll bar.
Only it knows how to map the scroll bar’s raw position information
into rows and columns, and that mapping is not exposed to you.

Now you can usually ask the grid to tell you what the topmost

visible row and leftmost visible column are. Is that enough?

-- Tim Roberts, ti...@probo.com
Providenza & Boekelheide, Inc.

steve wrote:

Maybe. I have 2 grids side by side. I want to scroll them
synchronously, that's why I need the position of the scrolls.

That kind of thing is always tricky. You might be better off thinking
about whether you can combine the two grids.

You can use XYToCell to tell you which cell is currently at the (0,0)
position. I suspect (after 10 seconds of thinking) that by itself would
be enough for you to keep the two in alignment.

···

--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.