[Urwid] Header With Right and Left Aligned Element

Ian Ward ian at excess.org
Wed Dec 13 14:14:02 EST 2006

Daniel Watkins wrote:
> As mentioned in my previous post, I'm an Urwid newbie (and this is one of the 
> trivial questions).
> I'm currently trying to put together a header which has a title in the top left 
> and another piece of info in the top right.
> At the moment I'm trying to use Columns, with little success. Is there a better 
> way to do this?

Columns is the best widget for what you're looking for.  If the text on 
the right or left is a fixed length then you can do something like:

header_widget = urwid.Columns([('fixed',10,left_widget), right_widget])

This way all the rest of the available width will be allocated to 

The only way to make right_widget appear on the right side at the moment 
is to use right-aligned text like:

right_widget = urwid.Text("I'm in the top right corner!", align="right")

In a future release I am planning to modify the Columns widget so that 
it can do right-alignment by detecting the width of the widgets it 
contains.. see: http://excess.org/urwid/ticket/11


More information about the Urwid mailing list