SmoothSizerMixin/SmoothBoxSizer

Mike Rooney wrote:

Robin Dunn wrote:

Looks good, although I notice that on some platforms the new button is visible at (0,0) while the slot for it is opening up. You might want to experiment with hiding the new item until you actually insert it into the sizer.

Will you try the new attached version and see if that fixes it? I used item.Hide() which I hope is the appropriate way to do it.

Looks good. You should add a test case however that inserts a sizer instead of a widget, and see what happens there.

I also got rid of the lambda and made it take milliseconds, and I attempted to return the SizerItems properly but that return is just going to be the result of the final CallLater which won't go anywhere, right?

Yes, however if you reuse the same sizer item for the final iteration, instead of detaching the spacer and inserting the item, then you can return the sizerItem from the first iteration where the programmer can grab it and save it if needed, and then the final result will be the same sizer item.

ยทยทยท

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

Robin Dunn wrote:

Mike Rooney wrote:

Robin Dunn wrote:

Looks good, although I notice that on some platforms the new button is visible at (0,0) while the slot for it is opening up. You might want to experiment with hiding the new item until you actually insert it into the sizer.

Will you try the new attached version and see if that fixes it? I used item.Hide() which I hope is the appropriate way to do it.

Looks good. You should add a test case however that inserts a sizer instead of a widget, and see what happens there.

Oh no, this doesn't work at all! I found two issues:

1) Getting the Size of the item, if it is a sizer, just returns (0, 0) because it has not been put anywhere and then Layout()'ed. Is there a way to, given a sizer and a subitem, find how much space the sizer WOULD assign the subitem? My workaround was not all that pretty:

  parentSizer.Add(subSizer)
  parentSizer.Layout()
  size = subSizer.Size
  parentSizer.Hide(subSizer)
  parentSizer.Detach(subSizer)
  parentSizer.Layout()

2) Calling item.Hide() works fine for instances of wx.Window, but sizers don't have a call that works in the same way that I could find. Basically I want a method that recursively hides all children, and then has a corresponding Show method. Doing this myself would be easy except that optimally it should remember state; ie, it is plausible that someone might add a sizer with an element already hidden, and we wouldn't want our Show() call to show this, only the items it hid on the Hide call.

I have attached the latest version, with the unfortunate size-obtaining code at line #167. The worst part is that it can't go in the mixin itself. A way around this would be to pass the mixins insert a tuple corresponding to which sizes are important, like (1, 0) to use the items width, perhaps. In this case the sizer logic could go in the mixin, at least.

Another small thing was that for some reason adding the sizers now requires a refresh on the window or else the top pixel of the item below it seems to get cut off (at least here on 2.8.1.1/WinXP). Comment out lines 147-148 and click the "Insert sizer..." button twice or more and you will see what I mean.

Any ideas for these issues? Thanks for all your time and correspondence on this!

- Mike Rooney

smoothsizer.py (8.93 KB)