scrolledpanel, again

I’m still having trouble getting ScrolledPanel to fit nicely into a Frame. I’ve appended the sample app; this doesn’t exactly reproduce all of my problems, but for a start, the frame doesn’t expand to show the full panels, but if I try to call Fit(), I end up with a blank white box - no widgets, no decorations, nothing. (wxPython 2.8.10.1, Python 2.6.4, OS X 10.6) I can’t set the frame size manually, because I won’t actually know how large the inner panel will be in advance.

By the way: SetMinSize() can’t be used to reduce the minimum size after it’s already been set once, correct? (This is problematic, but I can work around it if I can figure out the other bugs.)

thanks,

Nat

import wx, wx.lib.scrolledpanel

text = “The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.”

class MyFrame (wx.Frame) :

def init (self, *args, **kwds) :

wx.Frame.init(self, *args, **kwds)

top_panel = wx.Panel(self)

top_sizer = wx.BoxSizer(wx.VERTICAL)

top_panel.SetSizer(top_sizer)

panel = wx.lib.scrolledpanel.ScrolledPanel(top_panel, -1, style=wx.SUNKEN_BORDER)

panel.SetBackgroundColour((200,255,255))

top_sizer.Add(panel, 1, wx.ALL|wx.EXPAND)

panel_sizer = wx.BoxSizer(wx.VERTICAL)

panel.SetSizer(panel_sizer)

for i in range(10) :

panel_sizer.Add(wx.StaticText(panel, -1, text), 0, wx.ALL, 5)

btn_sizer = wx.BoxSizer(wx.HORIZONTAL)

show_btn = wx.Button(top_panel, -1, “Add widgets”)

self.Bind(wx.EVT_BUTTON, self.OnAdd, show_btn)

btn_sizer.Add(show_btn, 0, wx.ALL|wx.ALIGN_RIGHT, 5)

top_sizer.Add(btn_sizer, 0, wx.ALL|wx.ALIGN_RIGHT, 5)

self.panel_sizer = panel_sizer

self.panel = panel

self.top_panel = top_panel

self.top_sizer = top_sizer

self.panel_sizer.Layout()

self.panel.SetMinSize(self.panel.GetSize())

self.top_panel.SetMinSize(self.top_panel.GetSize())

self.reset_layout()

self.Refresh()

def OnAdd (self, event) :

for i in range(10) :

self.panel_sizer.Add(wx.StaticText(self.panel, -1, text), 0, wx.ALL, 5)

self.reset_layout()

def reset_layout (self) :

self.panel_sizer.Layout()

self.panel.SetupScrolling(scrollToTop=False)

self.top_sizer.Layout()

if name == “main” :

app = wx.App(0)

frame = MyFrame(None, -1, “Test”)

frame.Show()

app.MainLoop()

I'm still having trouble getting ScrolledPanel to fit nicely into a
Frame. I've appended the sample app; this doesn't exactly reproduce all
of my problems, but for a start, the frame doesn't expand to show the
full panels, but if I try to call Fit(), I end up with a blank white box
- no widgets, no decorations, nothing. (wxPython 2.8.10.1, Python
2.6.4, OS X 10.6) I can't set the frame size manually, because I won't
actually know how large the inner panel will be in advance.

Add this to your sample and it will help you see and experiment with how various things affect the layout: http://wiki.wxpython.org/Widget_Inspection_Tool

Hint: Pay attention to the scrolled panel's virtual size.

By the way: SetMinSize() can't be used to reduce the minimum size after
it's already been set once, correct?

No. Calling it won't actually change the size, but it will change the value used for the next layout.

···

On 1/6/10 2:09 PM, Nathaniel Echols wrote:

--
Robin Dunn
Software Craftsman

Okay, I’ve been meaning to figure this out but haven’t had time to fix another problem: it depends on stc, and I can’t figure out how to get that to build. I’m trying this:

./configure --with-mac --enable-monolithic [plus other stuff]

make

make -C contrib/src/stc

and it works right up until the end:

/usr/bin/libtool: can’t locate file for: -lwx_mac-2.8

/usr/bin/libtool: file: -lwx_mac-2.8 is not an object file (not allowed in a library)

which makes no sense, since the first ‘make’ doesn’t have this problem. Oddly, I also get the same error when it is finishing building the glcanvas module, but I still end up with the libwx_max_gl* libraries I expect. Am I missing something obvious again?

thanks,

Nat

···

On Wed, Jan 6, 2010 at 5:17 PM, Robin Dunn robin@alldunn.com wrote:

Add this to your sample and it will help you see and experiment with how various things affect the layout: http://wiki.wxpython.org/Widget_Inspection_Tool

    Add this to your sample and it will help you see and experiment with
    how various things affect the layout:
    http://wiki.wxpython.org/Widget_Inspection_Tool

Okay, I've been meaning to figure this out but haven't had time to fix
another problem: it depends on stc, and I can't figure out how to get
that to build. I'm trying this:

./configure --with-mac --enable-monolithic [plus other stuff]
make
make -C contrib/src/stc

and it works right up until the end:

/usr/bin/libtool: can't locate file for: -lwx_mac-2.8
/usr/bin/libtool: file: -lwx_mac-2.8 is not an object file (not allowed
in a library)

which makes no sense, since the first 'make' doesn't have this problem.

Well, that library is being made by the first make, so it wouldn't be trying to link with it. OTOH, the build for stc and the other extra libs should be able to find the core library with no problem...

  Oddly, I also get the same error when it is finishing building the
glcanvas module, but I still end up with the libwx_max_gl* libraries I
expect. Am I missing something obvious again?

The only thing I see is that you are building the library in-place instead of using a separate build dir. Try making a new empty folder somewhere (I usually use something like ../bld relative to the main wx source folder) and then cd into that dir and run configure using a relative or full pathname to the configure script. Then run the make command from the same location.

···

On 1/6/10 5:47 PM, Nathaniel Echols wrote:

On Wed, Jan 6, 2010 at 5:17 PM, Robin Dunn <robin@alldunn.com > <mailto:robin@alldunn.com>> wrote:

--
Robin Dunn
Software Craftsman