[Urwid] listbox

Rebecca Breu rebecca at rbreu.de
Tue Oct 17 08:49:55 EDT 2006


Zitat von Fabian Braennstroem <f.braennstroem at gmx.de>:

> Hi,
>
> me again :-)
>
> I am still looking for some features, which might be nice to
> have for a file manager. I would like to set different
> colors for the file names depending on the extension. Is
> this possible using a listbox? I saw that I can use
> 'palette' for basic color settings, but it looks like that I
> am not able to change the color from entry to entry!?

The palette defines only the "attributes" that you might use. But defining
a palette doesn't mean that those attributes are applied to anything. You
have to apply the attributes to the widgets manually using AttrWrap:

wrapped_widget = AttrWrap(my_widget, "my_attribute")

Widgets without their own attribute are rendered with the attribute of
the widget containing them (if any, otherwise with the default colours of
the terminal).

Try the attached program!


>
> Do you recommend using the listbox for such file entries at
> all? I would like to add the size, date and mode of the
> files in certain regions (columns) of the listbox. It would
> be some kind of table; e.g. like in Rebecca's 'unicore'.
> Would be nice, if you got any recommendations!

The ListBox is great! :)

For my "table", I used a Columns widgets with each column containing a
ListBox widget. So in your case that would be one ListBox with the filenames
in the first column, one ListBox with the according file sizes in the second
column etc. This approach gets a little tricky if you want rows of this table
to be selectable only as a whole, but I could post a stand alone version of the
Table widget I am using in the unicore configuration stuff, if you are
interested.


Rebecca

-------------- next part --------------
A non-text attachment was scrubbed...
Name: urwid_test.py
Type: text/x-python
Size: 840 bytes
Desc: not available
Url : http://lists.excess.org/pipermail/urwid/attachments/20061017/dd232b44/urwid_test.py


More information about the Urwid mailing list