In the attached program, I have a static text control. The contents of the
label may vary, but I want to 'reserve' a space for it so that the screen
maintains a consistent layout regardless of the actual contents. To do this
I pass it a 'size' parameter of (120,-1).
To simulate the behaviour I want, I added a 'Layout' button. Pressing it
causes the length of the label to be increased by one, and then Layout() is
called again. For this simple example it is not strictly necessary to call
Layout(), but in my live app I make other changes as well, so I do need it.
If I use wx.StaticText, it works as expected. The length of the label
increases, but the layout stays the same.
If I use GenStaticText, the initial display uses the size of (120,-1), but
subsequent calls to Layout() cause it to be reduced to the size of the
actual contents, and the rest of the screen is adjusted accordingly.
I have tried SetSize(), SetMinSize(), and SetSizeHints(), but they make no
difference.
This is using wxPython 2.8.0.1 on MSW and on GTK2.
In the attached program, I have a static text control. The contents of the
label may vary, but I want to 'reserve' a space for it so that the screen
maintains a consistent layout regardless of the actual contents. To do this
I pass it a 'size' parameter of (120,-1).
To simulate the behaviour I want, I added a 'Layout' button. Pressing it
causes the length of the label to be increased by one, and then Layout() is
called again. For this simple example it is not strictly necessary to call
Layout(), but in my live app I make other changes as well, so I do need it.
If I use wx.StaticText, it works as expected. The length of the label
increases, but the layout stays the same.
If I use GenStaticText, the initial display uses the size of (120,-1), but
subsequent calls to Layout() cause it to be reduced to the size of the
actual contents, and the rest of the screen is adjusted accordingly.
I have tried SetSize(), SetMinSize(), and SetSizeHints(), but they make no
difference.
Use style=wx.ST_NO_AUTORESIZE. It looks like the difference is that without that flag then the generic control uses SetInitialSize to reset the size (which also resets the min size) and the native controls just use SetSize. I'm pretty sure that the native ones also did the equivalent of SetInitialSize at one point in time, but apparently that has changed somewhere along the way. I'll update the generic widget to match.
ยทยทยท
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!