SHAIKH TAUSEEF HUSSAIN
2013-07-29 23:54:29 UTC
Hi Ian
I encountered some error on trying to run some tutorials at the link :
http://excess.org/urwid/docs/tutorial/index.html#urwid-tutorial
I tried to run the following code for high color modes :
#!/usr/bin/env python
import urwid
def exit_on_q(key):
if key in ('q', 'Q'):
raise urwid.ExitMainLoop()
palette = [
('banner', '', '', '', '#ffa', '#60d'),
('streak', '', '', '', 'g50', '#60a'),
('inside', '', '', '', 'g38', '#808'),
('outside', '', '', '', 'g27', '#a06'),
('bg', '', '', '', 'g7', '#d06'),]
placeholder = urwid.SolidFill()
loop = urwid.MainLoop(placeholder, palette, unhandled_input=exit_on_q)
loop.screen.set_terminal_properties(colors=256)
loop.widget = urwid.AttrMap(placeholder, 'bg')
loop.widget.original_widget = urwid.Filler(urwid.Pile([]))
div = urwid.Divider()
outside = urwid.AttrMap(div, 'outside')
inside = urwid.AttrMap(div, 'inside')
txt = urwid.Text(('banner', u" Hello World "), align='center')
streak = urwid.AttrMap(txt, 'streak')
pile = loop.widget.base_widget # .base_widget skips the decorations
for item in [outside, inside, streak, inside, outside]:
pile.contents.append((item, pile.options()))
loop.run()
This is the traceback for the error
$ ./highColorMode.py
Traceback (most recent call last):
File "./highColorMode.py", line 28, in <module>
pile.contents.append((item, pile.options()))
AttributeError: 'generator' object has no attribute 'append'
Does it mean there is a version problem with the urwid that i am using ?
I have a Mandriva linux system where I installed Urwid.
There is a folder /usr/share/doc/python-urwid// which has some examples.
*example1.4.py* at the above location refers to same high color modes
illustration
as given at the online tutorials site.
However the code for *example1.4.py* looks like below (which is different
from code at online site) :
#!/usr/bin/python
import urwid
palette = [
('banner', '', '', '', '#ffa', '#60d'),
('streak', '', '', '', 'g50', '#60a'),
('inside', '', '', '', 'g38', '#808'),
('outside', '', '', '', 'g27', '#a06'),
('bg', '', '', '', 'g7', '#d06'),]
txt = urwid.Text(('banner', u" Hello World "), align='center')
map1 = urwid.AttrMap(txt, 'streak')
pile = urwid.Pile([
urwid.AttrMap(urwid.Divider(), 'outside'),
urwid.AttrMap(urwid.Divider(), 'inside'),
map1,
urwid.AttrMap(urwid.Divider(), 'inside'),
urwid.AttrMap(urwid.Divider(), 'outside')])
fill = urwid.Filler(pile)
map2 = urwid.AttrMap(fill, 'bg')
def exit_on_q(input):
if input in ('q', 'Q'):
raise urwid.ExitMainLoop()
loop = urwid.MainLoop(map2, palette, unhandled_input=exit_on_q)
loop.screen.set_terminal_properties(colors=256)
loop.run()
The example code example1.4.py works whereas the code at the online site
does not work.
Could you explain if something is wrong with the code at the online site ?
I encountered some error on trying to run some tutorials at the link :
http://excess.org/urwid/docs/tutorial/index.html#urwid-tutorial
I tried to run the following code for high color modes :
#!/usr/bin/env python
import urwid
def exit_on_q(key):
if key in ('q', 'Q'):
raise urwid.ExitMainLoop()
palette = [
('banner', '', '', '', '#ffa', '#60d'),
('streak', '', '', '', 'g50', '#60a'),
('inside', '', '', '', 'g38', '#808'),
('outside', '', '', '', 'g27', '#a06'),
('bg', '', '', '', 'g7', '#d06'),]
placeholder = urwid.SolidFill()
loop = urwid.MainLoop(placeholder, palette, unhandled_input=exit_on_q)
loop.screen.set_terminal_properties(colors=256)
loop.widget = urwid.AttrMap(placeholder, 'bg')
loop.widget.original_widget = urwid.Filler(urwid.Pile([]))
div = urwid.Divider()
outside = urwid.AttrMap(div, 'outside')
inside = urwid.AttrMap(div, 'inside')
txt = urwid.Text(('banner', u" Hello World "), align='center')
streak = urwid.AttrMap(txt, 'streak')
pile = loop.widget.base_widget # .base_widget skips the decorations
for item in [outside, inside, streak, inside, outside]:
pile.contents.append((item, pile.options()))
loop.run()
This is the traceback for the error
$ ./highColorMode.py
Traceback (most recent call last):
File "./highColorMode.py", line 28, in <module>
pile.contents.append((item, pile.options()))
AttributeError: 'generator' object has no attribute 'append'
Does it mean there is a version problem with the urwid that i am using ?
I have a Mandriva linux system where I installed Urwid.
There is a folder /usr/share/doc/python-urwid// which has some examples.
*example1.4.py* at the above location refers to same high color modes
illustration
as given at the online tutorials site.
However the code for *example1.4.py* looks like below (which is different
from code at online site) :
#!/usr/bin/python
import urwid
palette = [
('banner', '', '', '', '#ffa', '#60d'),
('streak', '', '', '', 'g50', '#60a'),
('inside', '', '', '', 'g38', '#808'),
('outside', '', '', '', 'g27', '#a06'),
('bg', '', '', '', 'g7', '#d06'),]
txt = urwid.Text(('banner', u" Hello World "), align='center')
map1 = urwid.AttrMap(txt, 'streak')
pile = urwid.Pile([
urwid.AttrMap(urwid.Divider(), 'outside'),
urwid.AttrMap(urwid.Divider(), 'inside'),
map1,
urwid.AttrMap(urwid.Divider(), 'inside'),
urwid.AttrMap(urwid.Divider(), 'outside')])
fill = urwid.Filler(pile)
map2 = urwid.AttrMap(fill, 'bg')
def exit_on_q(input):
if input in ('q', 'Q'):
raise urwid.ExitMainLoop()
loop = urwid.MainLoop(map2, palette, unhandled_input=exit_on_q)
loop.screen.set_terminal_properties(colors=256)
loop.run()
The example code example1.4.py works whereas the code at the online site
does not work.
Could you explain if something is wrong with the code at the online site ?
--
Kind Regards
Tauseef Hussain
(tauseef at nitc dot ac dot in)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.excess.org/pipermail/urwid/attachments/20130730/7fb4b2c4/attachment-0001.htm
Kind Regards
Tauseef Hussain
(tauseef at nitc dot ac dot in)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.excess.org/pipermail/urwid/attachments/20130730/7fb4b2c4/attachment-0001.htm