Re: GetScrollPos() return 0 or 1 with wx.SHOW_SB_NEVER

Randle Taylor <[email protected]> Tue, 3 Nov 2020 11:27:22 -0800 (PST)
Newsgroups gmane.comp.python.wxpython
Message-ID <[email protected]>
For anyone else who comes across this issue with wxPython scrolled windows, 
I did as Tim Roberts suggested and GetViewStart worked nicely.  In my case 
I wanted to catch scroll events in a PropertyGrid and scroll the parent 
scrolled window instead which I was able to do like this:

def OnGridScroll(self, evt):  # self is a ScrolledPanel/Window
        pos = self.GetViewStart()[1]
        direction = 1 if evt.GetWheelRotation() < 0 else - 1
        offset = self.GetScrollPixelsPerUnit()[1]
        new_pos = max(0, pos + direction * offset)
        self.Scroll(0, new_pos)






On Thursday, September 24, 2015 at 1:08:32 PM UTC-4 Tim Roberts wrote:

> hudif wrote:
> >
> > I want to know scrolled position.
> > I use GetScrollPos(wx.VERTICAL) with
> > ShowScrollbars(wx.SHOW_SB_DEFAULT, wx.SHOW_SB_NEVER), it return only 0
> > or 1. Their value incorrect position.
>
> You just told ShowScrollbars to turn off vertical scrollbar. Was that a
> typo?
>
> There's a bit of a philosophy collision here. GetScrollPos is a native
> UI API that returns information about the native UI scroll bar for the
> current window. ShowScrollbars is part of wx.ScrolledWindow, which is
> doing magic to present a scrolled view of what would otherwise be a very
> large window. I'm not sure GetScrollPos will return anything meaningful
> here. You may have to use GetViewStart to find out what portion of the
> large window is currently visible.
>
> -- 
> Tim Roberts, [email protected]
> Providenza & Boekelheide, Inc.
>
>

-- 
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/wxpython-users/596c0c92-0959-4be9-8b48-0ecbeef85b19n%40googlegroups.com.