Discussion:
[Urwid] packing columns into a linebox
SHAIKH TAUSEEF HUSSAIN
2013-08-02 17:44:18 UTC
Permalink
hello Ian
I am reading a yml form file and getting its contents as columns in urwid.
I have to display these columns onto the console.
If I use a plain listbox and listwalker then i am able to get the columns
displayed on the screen.
However I need to group some of the columns as a block and show it in a
linebox widget.
How can I do so ?

Each column widget has two columns, the first one being text widget and
second one being edit widget.
This is what I tried :

1. tried to created a pile of columns by appending to a pile named as
blockPile (declared as blockPile = urwid.Pile([ ]) ) as in below :
blockPile.contents.append(column, options='pack')

but got this error

*TypeError: append() got an unexpected keyword argument 'options'*

2. then removed the options and used this :

blockPile.contents.append(listBoxCell)

*urwid.container.PileError: added content invalid: <Columns selectable
box/flow widget>*

3. Next I used listbox
blockContent = urwid.SimpleListWalker([])
blockListbox = urwid.ListBox(blockContent)

and used append to fit my columns inside it
blockContent.append(listBoxCell)

Finally to put the listbox in a box adapter

box = urwid.BoxAdapter(blockContent, height = 20)

and then to return it in a linebox
return urwid.LineBox(box, title='|** Block **|')

but now I get this error
*AttributeError: 'SimpleListWalker' object has no attribute 'selectable'
*


Everything works fine if I use only a listbox and a listwalker and don't
fit the listbox inside anything else.
But I want the list box of columns to be put in a linebox. How can I do so ?
--
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/20130802/170504f8/attachment.htm
Ian Ward
2013-08-04 19:10:56 UTC
Permalink
On Fri, Aug 2, 2013 at 1:44 PM, SHAIKH TAUSEEF HUSSAIN
Post by SHAIKH TAUSEEF HUSSAIN
1. tried to created a pile of columns by appending to a pile named as
blockPile.contents.append(column, options='pack')
but got this error
TypeError: append() got an unexpected keyword argument 'options'
There is an options() method you can use:
blockPile.contents.append((column, blockPile.options('pack')))
Post by SHAIKH TAUSEEF HUSSAIN
3. Next I used listbox
blockContent = urwid.SimpleListWalker([])
blockListbox = urwid.ListBox(blockContent)
and used append to fit my columns inside it
blockContent.append(listBoxCell)
Finally to put the listbox in a box adapter
box = urwid.BoxAdapter(blockContent, height = 20)
looks like this should be:
box = urwid.BoxAdapter(blockListbox, height=20)

Loading...