size = wx.DefaultSize, style = wx.TAB_TRAVERSAL,
name = "scrolledpanel"):
- wx.PyScrolledWindow.__init__(self, parent, -1,
+ wx.PyScrolledWindow.__init__(self, parent, id,
pos=pos, size=size,
style=style, name=name)
- self.SetBestSize(size)
+ self.SetBestFittingSize(size)
self.Bind(wx.EVT_CHILD_FOCUS, self.OnChildFocus)
if rate_y:
h += rate_y - (h % rate_y)
self.SetVirtualSize( (w, h) )
- self.SetVirtualSizeHints( w, h )
+ self.SetScrollRate(rate_x, rate_y)
+ wx.CallAfter(self._SetupAfter) # scroll back to top after initial events
- self.SetScrollRate(rate_x, rate_y)
- wx.CallAfter(self.Scroll, 0, 0) # scroll back to top after initial events
+
+ def _SetupAfter(self):
+ self.SetVirtualSize(self.GetBestVirtualSize())
+ self.Scroll(0,0)
def OnChildFocus(self, evt):
if cr.y < 0 and sppu_y > 0:
new_vs_y = vs_y + (cr.y / sppu_y)
-
# For the right and bottom edges, scroll enough to show the
# whole control if possible, but if not just scroll such that
# the top/left edges are still visible
else:
new_vs_y = vs_y + (cr.y / sppu_y)
-
# 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)