[Urwid] Resizing windows in urwid: how small is too small?
Ian Ward
ian at excess.org
Mon May 21 12:17:12 EDT 2007
James Reeves wrote:
> Ian Ward wrote:
>> I think that's a great idea. Florian Festi mentioned a similar
>> discomfort with the way Columns and Piles align widgets, but suggested
>> adding alignment attributes to the widgets as a solution. I like your
>> approach better because it lends itself more to Urwid's style of
>> widget-reuse and small, simple widget classes.
>>
>> I look forward to your patch :-)
>>
> I've adapted the Columns and Pile widgets to work with the layout hint
> wrappers. The code is essentially mostly unchanged; I just replaced all
> of the tuple-handling code with isinstance checks, etc. I also updated
> the unit tests in test_urwid.py.
>
> I'm undecided on the syntax, but it seems reasonable.
>
> What are your thoughts?
It looks pretty good, but I wonder if there is a way to do it in a more
duck-typing style.
Instead of isinstance() perhaps we could check for a size_hint attribute
and use it if it's there. That way people that know they are only using
"my_widget" in one container could just do something like:
my_widget.size_hint = 'weight'
my_widget.size_hint_weight = 5
I would prefer to name the classes FlowHint, WeightHint and FixedHint
and make them part of the urwid namespace (not a separate submodule), so
the same thing as above without modifying my_widget would be:
my_hinted_widget = urwid.WeightHint(my_widget, 5)
The hint classes could inherit from a new base class I'm planning to add
"DecoratorWidget". See: http://excess.org/urwid/wiki/NewBaseClasses
Ian
More information about the Urwid
mailing list