wx.lib.ScrolledPanel.py

When above is used and a control is not within the viewable area and I call spanel.ScrollChildIntoView(child) and the scrolled panel has a horizontal scrollbar then the child is just barely viewable after the call.

I like to suggest the following change to fix this:

Original code at about line 125 (wx 2.8.11):

         # if we need to adjust
         if new_vs_x != -1 or new_vs_y != -1:
             #print "%s: (%s, %s)" % (self.GetName(), new_vs_x, new_vs_y)
             self.Scroll(new_vs_x, new_vs_y)

Change:

         # if we need to adjust
         if new_vs_x != -1 or new_vs_y != -1:
             #print "%s: (%s, %s)" % (self.GetName(), new_vs_x, new_vs_y)
             if self.HasScrollbar(wx.HORIZONTAL):
                 new_vs_y += 15
             self.Scroll(new_vs_x, new_vs_y)

Werner

Hi,

When above is used and a control is not within the viewable area and I call
spanel.ScrollChildIntoView(child) and the scrolled panel has a horizontal
scrollbar then the child is just barely viewable after the call.

I like to suggest the following change to fix this:

Original code at about line 125 (wx 2.8.11):

   \# if we need to adjust
   if new\_vs\_x \!= \-1 or new\_vs\_y \!= \-1:
       \#print "%s: \(%s, %s\)" % \(self\.GetName\(\), new\_vs\_x, new\_vs\_y\)
       self\.Scroll\(new\_vs\_x, new\_vs\_y\)

Change:

   \# if we need to adjust
   if new\_vs\_x \!= \-1 or new\_vs\_y \!= \-1:
       \#print "%s: \(%s, %s\)" % \(self\.GetName\(\), new\_vs\_x, new\_vs\_y\)
       if self\.HasScrollbar\(wx\.HORIZONTAL\):
           new\_vs\_y \+= 15
       self\.Scroll\(new\_vs\_x, new\_vs\_y\)

If I am understanding correctly the issue your seeing, your saying
that the scrolling doesn't account for the horizontal scrollbar at the
bottom of the screen obscuring part of the view?

It would be better to get the scrollbar size from the system settings
instead of using a hard coded 15, as this can vary from system to
system.

new_vs_y += wx.SystemSettings.GetMetric(wx.SYS_HSCROLL_Y)

Cody

···

On Wed, Dec 1, 2010 at 8:58 AM, werner <wbruhin@free.fr> wrote:

Hi,

Hi,

When above is used and a control is not within the viewable area and I call
spanel.ScrollChildIntoView(child) and the scrolled panel has a horizontal
scrollbar then the child is just barely viewable after the call.

I like to suggest the following change to fix this:

Original code at about line 125 (wx 2.8.11):

        # if we need to adjust
        if new_vs_x != -1 or new_vs_y != -1:
            #print "%s: (%s, %s)" % (self.GetName(), new_vs_x, new_vs_y)
            self.Scroll(new_vs_x, new_vs_y)

Change:

        # if we need to adjust
        if new_vs_x != -1 or new_vs_y != -1:
            #print "%s: (%s, %s)" % (self.GetName(), new_vs_x, new_vs_y)
            if self.HasScrollbar(wx.HORIZONTAL):
                new_vs_y += 15
            self.Scroll(new_vs_x, new_vs_y)

If I am understanding correctly the issue your seeing, your saying
that the scrolling doesn't account for the horizontal scrollbar at the
bottom of the screen obscuring part of the view?

It would be better to get the scrollbar size from the system settings
instead of using a hard coded 15, as this can vary from system to
system.

new_vs_y += wx.SystemSettings.GetMetric(wx.SYS_HSCROLL_Y)

Good point, however further testing reveals that it is nothing to do with the ScrollBar but it is a rounding error in this:

         # is it below the bottom ?
         if cr.bottom > clntsz.height and sppu_y > 0:
             diff = (cr.bottom - clntsz.height + 1) / sppu_y
             if cr.y - diff * sppu_y > 0:
                 new_vs_y = vs_y + diff
             else:
                 new_vs_y = vs_y + (cr.y / sppu_y)

In my case this line "diff = (cr.bottom - clntsz.height + 1) / sppu_y" should return 6.85 but diff is set to 6.

A hack like this:

         # is it below the bottom ?
         if cr.bottom > clntsz.height and sppu_y > 0:
             diff = (cr.bottom - clntsz.height + 1) / sppu_y
             if cr.y - diff * sppu_y > 0:
                 new_vs_y = vs_y + diff + 1 # + 1 is to adjust for rounding
             else:
                 new_vs_y = vs_y + (cr.y / sppu_y)

Works for me, but it should probably be fixed in a way that the original calculation rounds to "7" in my case instead of returning 6.

Werner

···

On 01/12/2010 16:11, Cody Precord wrote:

On Wed, Dec 1, 2010 at 8:58 AM, werner<wbruhin@free.fr> wrote:

Could you test the attached patch for me?

Thanks.

scrolledpanel.patch (1.74 KB)

···

On 12/1/10 7:22 AM, werner wrote:

Hi,

On 01/12/2010 16:11, Cody Precord wrote:

Hi,

On Wed, Dec 1, 2010 at 8:58 AM, werner<wbruhin@free.fr> wrote:

When above is used and a control is not within the viewable area and
I call
spanel.ScrollChildIntoView(child) and the scrolled panel has a
horizontal
scrollbar then the child is just barely viewable after the call.

I like to suggest the following change to fix this:

Original code at about line 125 (wx 2.8.11):

# if we need to adjust
if new_vs_x != -1 or new_vs_y != -1:
#print "%s: (%s, %s)" % (self.GetName(), new_vs_x, new_vs_y)
self.Scroll(new_vs_x, new_vs_y)

Change:

# if we need to adjust
if new_vs_x != -1 or new_vs_y != -1:
#print "%s: (%s, %s)" % (self.GetName(), new_vs_x, new_vs_y)
if self.HasScrollbar(wx.HORIZONTAL):
new_vs_y += 15
self.Scroll(new_vs_x, new_vs_y)

If I am understanding correctly the issue your seeing, your saying
that the scrolling doesn't account for the horizontal scrollbar at the
bottom of the screen obscuring part of the view?

It would be better to get the scrollbar size from the system settings
instead of using a hard coded 15, as this can vary from system to
system.

new_vs_y += wx.SystemSettings.GetMetric(wx.SYS_HSCROLL_Y)

Good point, however further testing reveals that it is nothing to do
with the ScrollBar but it is a rounding error in this:

# is it below the bottom ?
if cr.bottom > clntsz.height and sppu_y > 0:
diff = (cr.bottom - clntsz.height + 1) / sppu_y
if cr.y - diff * sppu_y > 0:
new_vs_y = vs_y + diff
else:
new_vs_y = vs_y + (cr.y / sppu_y)

In my case this line "diff = (cr.bottom - clntsz.height + 1) / sppu_y"
should return 6.85 but diff is set to 6.

A hack like this:

# is it below the bottom ?
if cr.bottom > clntsz.height and sppu_y > 0:
diff = (cr.bottom - clntsz.height + 1) / sppu_y
if cr.y - diff * sppu_y > 0:
new_vs_y = vs_y + diff + 1 # + 1 is to adjust for rounding
else:
new_vs_y = vs_y + (cr.y / sppu_y)

Works for me, but it should probably be fixed in a way that the original
calculation rounds to "7" in my case instead of returning 6.

--
Robin Dunn
Software Craftsman

Hi Robin,

···

On 02/12/2010 00:54, Robin Dunn wrote:

On 12/1/10 7:22 AM, werner wrote:

Hi,

On 01/12/2010 16:11, Cody Precord wrote:

Hi,

On Wed, Dec 1, 2010 at 8:58 AM, werner<wbruhin@free.fr> wrote:

When above is used and a control is not within the viewable area and
I call
spanel.ScrollChildIntoView(child) and the scrolled panel has a
horizontal
scrollbar then the child is just barely viewable after the call.

I like to suggest the following change to fix this:

Original code at about line 125 (wx 2.8.11):

# if we need to adjust
if new_vs_x != -1 or new_vs_y != -1:
#print "%s: (%s, %s)" % (self.GetName(), new_vs_x, new_vs_y)
self.Scroll(new_vs_x, new_vs_y)

Change:

# if we need to adjust
if new_vs_x != -1 or new_vs_y != -1:
#print "%s: (%s, %s)" % (self.GetName(), new_vs_x, new_vs_y)
if self.HasScrollbar(wx.HORIZONTAL):
new_vs_y += 15
self.Scroll(new_vs_x, new_vs_y)

If I am understanding correctly the issue your seeing, your saying
that the scrolling doesn't account for the horizontal scrollbar at the
bottom of the screen obscuring part of the view?

It would be better to get the scrollbar size from the system settings
instead of using a hard coded 15, as this can vary from system to
system.

new_vs_y += wx.SystemSettings.GetMetric(wx.SYS_HSCROLL_Y)

Good point, however further testing reveals that it is nothing to do
with the ScrollBar but it is a rounding error in this:

# is it below the bottom ?
if cr.bottom > clntsz.height and sppu_y > 0:
diff = (cr.bottom - clntsz.height + 1) / sppu_y
if cr.y - diff * sppu_y > 0:
new_vs_y = vs_y + diff
else:
new_vs_y = vs_y + (cr.y / sppu_y)

In my case this line "diff = (cr.bottom - clntsz.height + 1) / sppu_y"
should return 6.85 but diff is set to 6.

A hack like this:

# is it below the bottom ?
if cr.bottom > clntsz.height and sppu_y > 0:
diff = (cr.bottom - clntsz.height + 1) / sppu_y
if cr.y - diff * sppu_y > 0:
new_vs_y = vs_y + diff + 1 # + 1 is to adjust for rounding
else:
new_vs_y = vs_y + (cr.y / sppu_y)

Works for me, but it should probably be fixed in a way that the original
calculation rounds to "7" in my case instead of returning 6.

Could you test the attached patch for me?

Works perfectly.

Thanks
Werner