Urwid colored Text simplified
<p>This is my broken code (technically works but doesn't change color)</p>

<pre><code>import urwid
txt = urwid.AttrMap(urwid.Text(u"Hello World"), 'dark blue')
fill = urwid.Filler(txt, 'top')
loop = urwid.MainLoop(fill)
loop.run()
</code></pre>

<p>Honestly all I want to do is change the color of the text, it seems so simple of a task but with urwid, a little confusing.</p>

<p>Here's how they did it in their example: <a href="https://github.com/urwid/urwid/blob/5c7bff3d381e855b483b7b65688ce2d4f53cdd1b/docs/manual/safe_combinations.py" rel="nofollow">https://github.com/urwid/urwid/blob/5c7bff3d381e855b483b7b65688ce2d4f53cdd1b/docs/manual/safe_combinations.py</a></p>

<p>From the <a href="http://urwid.org/reference/widget.html#text" rel="nofollow">manual</a>, there is no argument for color:</p>

<blockquote>
  <p>class urwid.Text(markup, align='left', wrap='space', layout=None)</p>
</blockquote>

<p>You have to define a pallet, example:</p>

<pre><code>import urwid

palette = [("text", "dark blue", 'white')]

text = urwid.Text(("text", u'Hello World'))
fill = urwid.Filler(text, 'top')
urwid.MainLoop(fill, palette).run()
</code></pre>

<p><a href="http://i.stack.imgur.com/XQXd3.gif" rel="nofollow"><img src="http://i.stack.imgur.com/XQXd3.gif" alt="enter image description here"></a></p>

<p>For Display attributes, visit: <a href="http://urwid.org/tutorial/index.html#display-attributes" rel="nofollow">http://urwid.org/tutorial/index.html#display-attributes</a></p>

<p>You can follow some advanced examples at: <a href="http://urwid.org/examples/index.html" rel="nofollow">http://urwid.org/examples/index.html</a></p>

python python-2.7