On Mon, Nov 23, 2009 at 6:00 AM, Ian Ward <[email protected]> wrote:
> Dominic LoBue wrote:
>> Also, a suggestion: with the addition of the event loops in 0.9.9,
>> instead of having to pass the (maxcol, maxrow), to each and every
>> widget, why don't you store it in an attribute for big widgets, and
>> only update or recalculate them when the terminal is resized? You
>> could have the event loop send out a global "resized" signal with the
>> new (maxcol, maxrow) so terminal resizings are handled properly.
>
> In my earliest, unreleased versions of Urwid, widgets would store their
> size in this manner.
>
> First I gave all the widgets a resize method, that could be used to
> update these values on a resize event.  The topmost widget would resize
> its children etc.
>
> The first problem was with new widgets getting added to a ListBox: they
> don't know what their size is, so now I have to call resize every time
> before calling render.
>
> An alternate solution I started working on was to have each widget ask
> its parent what its size should be, if it needs to know.  But then I
> have all sorts of code passing around parent pointers, and I *still*
> need the resize method.
>
> I was accumulating a pile of code that did nothing but maintain widget
> sizes.  And, when I got it wrong it would break in strange and
> unpredictable ways.
>
> The current scheme requires no parent pointers in the widgets, so
> widgets are a nice simple tree structure (also letting you reuse widgets
> in multiple places) although it does create a burden in the cases where
> you really do want to know the size of a widget.
>
> It's not a perfect solution, but in my opinion it's better than the
> alternative.
>
> Once the widgets are rendered, it is possible to use the canvases
> generated to get size and screen position information (it will always be
> the last size a widget was rendered at), but I haven't decided on the
> interface to make that easier to do yet.
>
> Ian
>
> _______________________________________________
> Urwid mailing list
> [email protected]
> http://lists.excess.org/mailman/listinfo/urwid
>

Ah, I hadn't realized.

Oh well, thought it was worth mentioning.

Dominic

_______________________________________________
Urwid mailing list
[email protected]
http://lists.excess.org/mailman/listinfo/urwid

Reply via email to