ItemsPicker/ListBox resizing problems

Hi,

I'm having problems getting an ItemsPicker to resize properly.

An ItemsPicker contains two ListBox'es which have the same sizer
proportion. Yet when the frame is made smaller, at some point the
left-hand side ListBox stops shrinking, while the right-hand size
ListBox gradually disappears.

The ListBox size where this starts to happen is the ListBox "best"
size. BestSize is dynamically computed from the content, as the width
of the widest string plus room for a scrollbar plus some extra space
to look pretty. That would be all well and good except the sizing
algorithms treat BestSize as some sort of /minimum/ size for the
widget, for reasons I don't understand.

So, my question: Is there any way to control (reduce) the best
size, or otherwise make the ListBoxen resize proportionally?

If it matters, I'm on 3.0.2 classic, msw 32 bit.

Here's a simple demo program to show the problem.

import wx
from wx.lib import itemspicker, inspection
app = wx.App()
fr = wx.Frame(None, -1)
pa = itemspicker.ItemsPicker(fr, choices=list('hello')+['a much longer text, indeed'])
pa.SetSelections(list('world'))
fr.Show(True)
inspection.InspectionTool().Show()
app.MainLoop()

best regards, Anders

···

********************************************************************************
Denne mail er blevet scannet af http://www.comendo.com og indeholder ikke virus!
********************************************************************************

Anders Munch wrote:

Hi,

I'm having problems getting an ItemsPicker to resize properly.

An ItemsPicker contains two ListBox'es which have the same sizer
proportion. Yet when the frame is made smaller, at some point the
left-hand side ListBox stops shrinking, while the right-hand size
ListBox gradually disappears.

The ListBox size where this starts to happen is the ListBox "best"
size. BestSize is dynamically computed from the content, as the width
of the widest string plus room for a scrollbar plus some extra space
to look pretty. That would be all well and good except the sizing
algorithms treat BestSize as some sort of /minimum/ size for the
widget, for reasons I don't understand.

So, my question: Is there any way to control (reduce) the best
size, or otherwise make the ListBoxen resize proportionally?

If it is set then the min size will override the best size, so setting the min size to some small value will give you the effect you want, for example:

import wx
from wx.lib import itemspicker, inspection

app = wx.App()
fr = wx.Frame(None, -1)
pa = itemspicker.ItemsPicker(fr, choices=list('hello')+['a much longer text, indeed'])
pa.SetSelections(list('world'))

for child in pa.Children:
     if isinstance(child, wx.ListBox):
         child.SetMinSize((10,-1))

fr.Show(True)

inspection.InspectionTool().Show()
app.MainLoop()

···

--
Robin Dunn
Software Craftsman