Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo


#11 Preferred widget sizes

widgets (7)
Chris Rodrigues

I have found it quite a nuisance to have to iteratively adjust pixel
placement and sizing of widgets to get a good-looking dialog box.
So, I propose that widgets have "preferred sizes" that layout
managers will attempt to honor.

Widgets could have a function "getPreferredSize" that returns the
widget's recommended (w,h) size. The Base implementation would be
to return the widget's current size, but it is overriden, for example, by
buttons, which are usually fixed-height. One way layout managers
could honor this is by checking whether the preferred width or
height of a widget is smaller than the size allocated to it; if so, then it
will only make the widget that size, and it will center the widget within
its space.

If this is implemented, then there should also be a way of saying that
a widget does not have a preferred size, for example by returning a
(None, None) tuple.


  • Logged In: YES

    I did some editing and created a patch. FlowLayoutManager now supports
    the friendly layout format.

    Widgets have two size hinting functions, getPreferredSize and
    getMaximumSize. getMaximumSize can return the special value 'Much',
    which means as big as possible. (Much has similar arithmetic properties to
    +infinity. Creating this value made the math simpler.) The widgets that
    implement meaningful size hinting now are Label, Picture, Button, and Edit.

    FlowLayoutManager makes use of the size hints. It also allows objects to be
    aligned vertically within their spaces, or force-stretched to fit the entire

    It remains to convert the other layout managers and widgets to honoring
    this protocol. It looks like the protocol can be deployed incrementally.

    The widgets should probably query the themes to get their preferred sizes,
    (for example: ThemeBase.getImageButtonSize()) because the desired size
    probably depends on how the widget is drawn.

  • Sean Riley
    Sean Riley

    Logged In: YES

    patch applied for the 0.96 release

  • Sean Riley
    Sean Riley

    • status: open --> closed