In response to my own message, I've found the following workaround.
So my question is now: Is the behaviour in my first example a bug or a
feature? Equivalently: Is my second example a workaround or the correct way
to do what I wanted to do?
If it is a bug should I log it somewhere?
Cheers,
Rich
···
====================================
from wxPython.wx import *
class MyFrame(wxFrame):
def __init__(self):
wxFrame.__init__(self,None,-1,"Scrolling problems - Fixed")
scroller = wxScrolledWindow(self,-1)
panel = wxPanel(scroller,-1)
sizer = wxBoxSizer(wxVERTICAL)
for i in xrange(1,200):
sizer.Add(wxStaticText(panel,-1,`i`),0,wxALIGN_LEFT,0)
sizer.CalcMin()
(x,y) = sizer.GetMinSize()
scroller.SetScrollbars(10, 10, x/10+1, y/10+1)
panel.SetAutoLayout(true)
panel.SetSizer(sizer)
panel.SetClientSize((x,y))
sizer.Layout()
self.Show(1)
class MyApp(wxApp):
def OnInit(self):
frame = MyFrame()
frame.Show(true)
self.SetTopWindow(frame)
return true
app = MyApp(0)
app.MainLoop()
-----Original Message-----
From: Richard Cooper
Sent: 11 March 2002 18:20
To: 'wxpython-users@lists.wxwindows.org'
Subject: wxScrolledWindow and Sizers
I am having a problem with laying out widgets within a wxScrolledWindow. In
the following program whenever you resize the window the widgets are laid
out as if the scroll bar was at the origin regardless of where it actually
is.
That's probably a really bad description of what's happening so run the
program, scroll down a bit and resize to see what I mean.
Any help would be greatly appreciated.
Cheers,
Rich.
====================================
from wxPython.wx import *
class MyFrame(wxFrame):
def __init__(self):
wxFrame.__init__(self,None,-1,"Scrolling problems")
scroller = wxScrolledWindow(self,-1)
sizer = wxBoxSizer(wxVERTICAL)
for i in xrange(1,200):
sizer.Add(wxStaticText(scroller,-1,`i`),0,wxALIGN_LEFT,0)
sizer.CalcMin()
(x,y) = sizer.GetMinSize()
scroller.SetScrollbars(10, 10, x/10+1, y/10+1)
scroller.SetAutoLayout(true)
scroller.SetSizer(sizer)
sizer.Layout()
self.Show(1)
class MyApp(wxApp):
def OnInit(self):
frame = MyFrame()
frame.Show(true)
self.SetTopWindow(frame)
return true
app = MyApp(0)
app.MainLoop()