[Urwid] Centering Button Text

Ian Ward ian at excess.org
Tue Apr 10 09:17:23 EDT 2012

On Tue, Apr 10, 2012 at 6:36 AM, Andrew Higginson
<at.higginson at gmail.com> wrote:
> Hi,
> So I am new to urwid and need some help :)
> I have a set of buttons packed with an urwid.Columns and I would like
> the text inside each buttons to be centered
> Currently it looks like this  but as you can see, the text is aligned to
> the left
> If there is not a method/easy way to achieve this, and it requires some
> sub-classing, could you give me some pointers on how to do it?

Button's _label attribute is a Text subclass, so this works:

  my_button._label.align = 'center'

You could add that to the __init__ of a Button subclass if you like.


More information about the Urwid mailing list