What would you expect to get from print there? (1,1)? Yeah, me too, but I always get (10, 10).
If I replace any of the 1's in SetMinSize(), they are ignored if they are < 10.
I'm asking: Why is that.
And more importantly: How can I force a sizer to be as small as (1,1) or better (0,0)? (meaning that they are invisible as long as they have no children)
BTW: I'm running Python 2.5RC2 and wxPython 2.6.3.3 on a WinXP SP2 machine.
What would you expect to get from print there? (1,1)? Yeah, me too, but I always get (10, 10).
If I replace any of the 1's in SetMinSize(), they are ignored if they are < 10.
I'm asking: Why is that.
And more importantly: How can I force a sizer to be as small as (1,1) or better (0,0)? (meaning that they are invisible as long as they have no children)
BTW: I'm running Python 2.5RC2 and wxPython 2.6.3.3 on a WinXP SP2 machine.
So it calculates the minsize needed for the contents of the sizer, and then adjusts that with the set min size if needed. If there are no items in the sizer then they return (10,10) from CalcMin. I'm not sure why.
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!
So it calculates the minsize needed for the contents of the sizer, and then adjusts that with the set min size if needed. If there are no items in the sizer then they return (10,10) from CalcMin. I'm not sure why.
Ah, interesting ...
So it appears the easiest/most obvious way to make a sizer smaller is to change the m_minSize members, right? I can't find them doc'ed, and they are certainly not members of the wx.BoxSizer class.
Any pointers? (I've got the feeling I've just missed something very obvious.)
So it calculates the minsize needed for the contents of the sizer, and then adjusts that with the set min size if needed. If there are no items in the sizer then they return (10,10) from CalcMin. I'm not sure why.
Ah, interesting ...
So it appears the easiest/most obvious way to make a sizer smaller is to change the m_minSize members, right? I can't find them doc'ed, and they are certainly not members of the wx.BoxSizer class.
Any pointers? (I've got the feeling I've just missed something very obvious.)
You have. The (10,10) comes from the call to CalcMin() when there are no items in the sizer. The m_minSize member is set with your call to SetMinSize, but it is overridden by the (10,10) returned from CalcMin, so the way to get a smaller size is to add a spacer to the sizer that has a size of (0,0) (this is untested, but should work.)
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!
You have. The (10,10) comes from the call to CalcMin() when there are no items in the sizer. The m_minSize member is set with your call to SetMinSize, but it is overridden by the (10,10) returned from CalcMin, so the way to get a smaller size is to add a spacer to the sizer that has a size of (0,0) (this is untested, but should work.)
I was actually thinking about that but decided against it. It somehow felt hackish. So I did it the hard way by overriding GetMinSize(). Here is the code, just for the record (and criticism):
def GetMinSize(self):
"""Extended in order to allow sizes smaller than (10, 10)
(which, weirdly, a normal Sizer can not obtain)."""
size = wx.BoxSizer.GetMinSize(self)
if not self.GetChildren():
size = wx.Size(0, 0)
return size
# another implementation I tried (both seem to be equal)
# This is the cumbersome way of doing it manually.
# Initial size is zero.
size = wx.Size(0, 0)
# Iterate over the sizer's items to determine the minsize.
for item in self.GetChildren():
# if the current size is smaller than needed, grow appropriately.
itemsize = item.GetSize()
if size.x < itemsize.x: size.x = itemsize.x
if size.y < itemsize.y: size.y = itemsize.y
return size
Thanks for the help. I'm not sure if I'm any wiser than before, but at least I have my invisible sizers :).