[wxpython-dev] wxGridBagSizer and hidden items broken in 2.8.8.0

wxPython developer mailing list, post #744
Author:
Date:
Subject:
 Kevin Watters
 2008-07-03 15:43:54
 [wxpython-dev] wxGridBagSizer and hidden items broken in 2.8.8.0
Going from 2.8.7.1 to 2.8.8.0 I noticed that some of my windows using
wxGridBagSizer looked strange.

It looks if you hide an item that's in a GBSizer, the sizer calculates its
minimum like the item was still shown. There's a small demo and an image of the
difference between 2.8.7.1 - 2.8.8.0 here:

http://papernapkin.org/pastebin/view/1477/

And here's the demo code reproduced in case that goes away:

import wx

def test_HiddenItem():
f = wx.Frame(None)

f.Sizer = fx = wx.GridBagSizer(6, 6)
fx.SetEmptyCellSize((0, 0))

s1 = wx.StaticText(f, -1, 'Test one two three')
s2 = wx.StaticText(f, -1, 'Test four five six')
s3 = wx.StaticText(f, -1, 'Test seven eight nine')

# hide the middle item: it still takes up space in 2.8.8.0
s2.Hide()

fx.Add(s1, (0, 0))
fx.Add(s2, (1, 0))
fx.Add(s3, (2, 0))

f.Show()

def main():
a = wx.PySimpleApp()
test_HiddenItem()
a.MainLoop()

if __name__ == '__main__':
main()

I noticed a backport involving a flag called wxRESERVE_SPACE_EVEN_IF_HIDDEN but
I haven't had time to check it out yet.

_______________________________________________
wxpython-dev mailing list
[email protected]
http://lists.wxwidgets.org/mailman/listinfo/wxpython-dev
Author:
Date:
Subject:
 Kevin Watters
 2008-07-03 15:58:35
 [wxpython-dev] Re: wxGridBagSizer and hidden items broken in 2.8.8.0
> It looks if you hide an item that's in a GBSizer, the sizer calculates its
> minimum like the item was still shown. There's a small demo and an image of the
> difference between 2.8.7.1 - 2.8.8.0 here:
>
> http://papernapkin.org/pastebin/view/1477/
>

This particular case is fixed if I change

if ( !item )

in wxGridBagSizer::AdjustForOverflow() to

if ( !item || !item->ShouldAccountFor() )

I'm not entirely sure if this is correct, but it seems to work for me :)

- Kevin

_______________________________________________
wxpython-dev mailing list
[email protected]
http://lists.wxwidgets.org/mailman/listinfo/wxpython-dev
Author:
Date:
Subject:
 Robin Dunn
 2008-07-03 10:54:18
 Re: [wxpython-dev] Re: wxGridBagSizer and hidden items broken in 2.8.8.0
Kevin Watters wrote:
>> It looks if you hide an item that's in a GBSizer, the sizer calculates its
>> minimum like the item was still shown. There's a small demo and an image of the
>> difference between 2.8.7.1 - 2.8.8.0 here:
>>
>> http://papernapkin.org/pastebin/view/1477/
>>
>
> This particular case is fixed if I change
>
> if ( !item )
>
> in wxGridBagSizer::AdjustForOverflow() to
>
> if ( !item || !item->ShouldAccountFor() )
>
> I'm not entirely sure if this is correct, but it seems to work for me :)

Thanks. I'll dig up my test case for that change and try it out with
your modification. I think that the ShouldAccountFor code happened at
about the same time as my AdjustForOverflow change so there wasn't any
cross-checking because neither of us understood the other's motivations ;-)

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

_______________________________________________
wxpython-dev mailing list
[email protected]
http://lists.wxwidgets.org/mailman/listinfo/wxpython-dev