Discussion:
[Urwid] Pile does not support append
SHAIKH TAUSEEF HUSSAIN
2013-07-29 23:54:29 UTC
Permalink
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 ?
--
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
Keith Dart
2013-07-30 04:59:54 UTC
Permalink
On Tue, 30 Jul 2013 02:54:29 +0300
Post by SHAIKH TAUSEEF HUSSAIN
$ ./highColorMode.py
File "./highColorMode.py", line 28, in <module>
pile.contents.append((item, pile.options()))
AttributeError: 'generator' object has no attribute 'append'
What version of python are you using?
--
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Keith Dart <keith at dartworks.biz>
public key: ID: 19017044
<http://www.dartworks.biz/>
=====================================================================
SHAIKH TAUSEEF HUSSAIN
2013-07-30 16:03:12 UTC
Permalink
I seem to have both python 2.7 and python 3 installed as given by output
below :
$ pyth
python python2.7 python2-config python3-2to3
python3.3m
python2 python2.7-config python3 python3.3
python-config

but urwid library is at
/usr/lib64/python2.7/site-
packages

So I guess I am using python2.7.
Send Urwid mailing list submissions to
urwid at lists.excess.org
To subscribe or unsubscribe via the World Wide Web, visit
http://lists.excess.org/mailman/listinfo/urwid
or, via email, send a message with subject or body 'help' to
urwid-request at lists.excess.org
You can reach the person managing the list at
urwid-owner at lists.excess.org
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Urwid digest..."
1. Re: Pile does not support append (Keith Dart)
----------------------------------------------------------------------
Message: 1
Date: Mon, 29 Jul 2013 21:59:54 -0700
From: Keith Dart <keith at dartworks.biz>
Subject: Re: [Urwid] Pile does not support append
To: Urwid General Discussion <urwid at lists.excess.org>
Cc: tauseef at nitc.ac.in
Message-ID: <20130729215954.59d18a0b at dartworks.biz>
Content-Type: text/plain; charset=US-ASCII
On Tue, 30 Jul 2013 02:54:29 +0300
Post by SHAIKH TAUSEEF HUSSAIN
$ ./highColorMode.py
File "./highColorMode.py", line 28, in <module>
pile.contents.append((item, pile.options()))
AttributeError: 'generator' object has no attribute 'append'
What version of python are you using?
--
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Keith Dart <keith at dartworks.biz>
public key: ID: 19017044
<http://www.dartworks.biz/>
=====================================================================
------------------------------
_______________________________________________
Urwid mailing list
Urwid at lists.excess.org
http://lists.excess.org/mailman/listinfo/urwid
End of Urwid Digest, Vol 92, Issue 7
************************************
--
Kind Regards
Tauseef Hussain
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.excess.org/pipermail/urwid/attachments/20130730/f9f19efe/attachment.htm
SHAIKH TAUSEEF HUSSAIN
2013-07-31 18:53:04 UTC
Permalink
I happened to come across a similar problem at
http://stackoverflow.com/questions/14693288/i-am-unable-to-get-urwid-tutorial-examples-to-work/14695915#14695915and
I realised the code on the site for urwid examples are meant to be
used
with new urwid version
whereas the version that comes with my mandriva os system is older.
Now the code from the urwid tutorials link work fine.

best
Tauseef


On Tue, Jul 30, 2013 at 12:03 PM, SHAIKH TAUSEEF HUSSAIN <tauseef at nitc.ac.in
Post by SHAIKH TAUSEEF HUSSAIN
I seem to have both python 2.7 and python 3 installed as given by output
$ pyth
python python2.7 python2-config python3-2to3
python3.3m
python2 python2.7-config python3 python3.3
python-config
but urwid library is at
/usr/lib64/python2.7/site-
packages
So I guess I am using python2.7.
Send Urwid mailing list submissions to
urwid at lists.excess.org
To subscribe or unsubscribe via the World Wide Web, visit
http://lists.excess.org/mailman/listinfo/urwid
or, via email, send a message with subject or body 'help' to
urwid-request at lists.excess.org
You can reach the person managing the list at
urwid-owner at lists.excess.org
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Urwid digest..."
1. Re: Pile does not support append (Keith Dart)
----------------------------------------------------------------------
Message: 1
Date: Mon, 29 Jul 2013 21:59:54 -0700
From: Keith Dart <keith at dartworks.biz>
Subject: Re: [Urwid] Pile does not support append
To: Urwid General Discussion <urwid at lists.excess.org>
Cc: tauseef at nitc.ac.in
Message-ID: <20130729215954.59d18a0b at dartworks.biz>
Content-Type: text/plain; charset=US-ASCII
On Tue, 30 Jul 2013 02:54:29 +0300
Post by SHAIKH TAUSEEF HUSSAIN
$ ./highColorMode.py
File "./highColorMode.py", line 28, in <module>
pile.contents.append((item, pile.options()))
AttributeError: 'generator' object has no attribute 'append'
What version of python are you using?
--
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Keith Dart <keith at dartworks.biz>
public key: ID: 19017044
<http://www.dartworks.biz/>
=====================================================================
------------------------------
_______________________________________________
Urwid mailing list
Urwid at lists.excess.org
http://lists.excess.org/mailman/listinfo/urwid
End of Urwid Digest, Vol 92, Issue 7
************************************
--
Kind Regards
Tauseef Hussain
--
Kind Regards
Tauseef Hussain
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.excess.org/pipermail/urwid/attachments/20130731/9100f0b5/attachment.htm
Ian Ward
2013-08-04 18:53:53 UTC
Permalink
On Mon, Jul 29, 2013 at 7:54 PM, SHAIKH TAUSEEF HUSSAIN
Post by SHAIKH TAUSEEF HUSSAIN
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
Yes, it sounds like the version included with Mandriva is too old to
run the latest examples. Get a newer copy of Urwid with virtualenv
and pip or remove the Mandriva packaged one and install Urwid from
source.

Loading...