[Urwid] example of maxrow (or height?)

Ian Ward ian at excess.org
Wed Nov 16 17:29:12 EST 2011


Kurt Yoder wrote on 2011-11-16 15:28:
> On Nov 16, 2011, at 1:35 PM, Ian Ward wrote:
> 
>> Hi Kurt,
>>
>> Kurt Yoder wrote on 2011-11-16 13:26:
>>> All,
>>>
>>> I am trying to make a text input box containing a long block of text.
>>> But this input box must share vertical space with other widgets, so I
>>> don't want it to expand to display everything inside the input box.
>>> Is there a commonly-accepted way to do this? For example, if the
>>> screen shows:
>>>
>>> widget1 widget2 biginput1 biginput2
>>>
>>> can I tell biginput1 and 2 to both constrain themselves to maximum 5
>>> rows? It seems the documentation refers to "maxrow", but I can't find
>>> an example of how to do this.
>>
>> What would you like to happen when the content of the text exceeds 5 rows?
> 
> I would like the text to be cut off, but "scroll" into view when I place my cursor within and then press the down/up arrows.

Here's an example that does that:

urwid.MainLoop(
    urwid.Filler(
        urwid.BoxAdapter(
            urwid.Filler(
                urwid.Edit(u"Type lots:", u"", multiline=True),
                'top'),
            5),
        'top')
    ).run()

You likely just need the BoxAdapter and inner Filler.

Ian



More information about the Urwid mailing list