Search code examples
wxpython

Does wxPython have a native FlowLayoutManager/FlowSizer/WrapSizer implementation?


I am trying to write a GUI in wxPython 2.8 (with Python 2.7) that involves laying out several wx.StaticTexts in a sizer. What I want is a sizer that will automatically add any additional elements to a new row if it detects that the width of the current row is wider than the width of the window.

Research tells me that this would be analogous to a Java FlowLayoutManager and that wxWidgets, the project that wxPython is attempting to port to Python has this as a wxWrapSizer. However, as far as I can tell, wxWrapSizer does not exist in wxPython. Documentation can be found here: http://docs.wxwidgets.org/trunk/classwx_wrap_sizer.html

Does wxPython natively support this?

Thank you for your help.

Note:

I can't use a single wx.StaticText and call wx.StaticText.Wrap(width) because I need to track the items seperately. If it helps, pretend that instead of wx.StaticTexts they are images.

I found an implementation submitted to wxpython-users.com from 2006. I'd prefer to use something built into wxPython but worst case scenario I can give it a try. http://wxpython-users.1045709.n5.nabble.com/Flow-Sizer-td2339182.html


Solution

  • wx.WrapSizer is wrapped in wxPython 2.9. If you upgrade to that, you'll have that widget available.