]> git.saurik.com Git - wxWidgets.git/blobdiff - wxPython/wx/lib/scrolledpanel.py
Migate to the new wxRendererNative::DrawItemSelectionRect function where available...
[wxWidgets.git] / wxPython / wx / lib / scrolledpanel.py
index 851d9332fa9a075dd7e32466f680e7c1f07af3a5..1d92901f9e85c567552a47acdfa5fa1ad76c7fab 100644 (file)
@@ -35,10 +35,10 @@ class ScrolledPanel( wx.PyScrolledWindow ):
                  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.SetBestFittingSize(size)
+        self.SetInitialSize(size)
         self.Bind(wx.EVT_CHILD_FOCUS, self.OnChildFocus)
 
 
@@ -65,10 +65,13 @@ class ScrolledPanel( wx.PyScrolledWindow ):
             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):
@@ -91,7 +94,6 @@ class ScrolledPanel( wx.PyScrolledWindow ):
         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
@@ -112,7 +114,6 @@ class ScrolledPanel( wx.PyScrolledWindow ):
             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)