[Urwid] Re: newbie looks for more examples

Ian Ward ian at excess.org
Fri Aug 25 23:21:30 EDT 2006

Fabian Braennstroem wrote:
>   File "/home/fab/Desktop/lfm/actions.py", line 189, in do
>     exec(act)
>   File "<string>", line 1, in ?
> AttributeError: DialogDisplay instance has no __call__ method
> Right now, I have no clue, what the last line means. Maybe, it is a simple
> python/urwid problem and you do not have to know the whole lfm code to give
 > some tips!? Would be nice to use urwid for it.

Well, this error suggests that lfm is trying to use the result of the 
exec statement as a function and call it.  Perhaps the "act" string is 
modified from what was in the dictionary -- you can get really strange 
behaviours from code that does tricks with exec statements.

But a larger issue is that Urwid wasn't designed to be integrated 
peicemeal into curses applications. It was designed to wrap curses.

One problem you'll run into is that Urwid sets up the curses palette and 
remembers the colour pair indexes.  In an existing curses application it 
will have already set up the palette on its own, so it will take some 
maneuvering to make colours work properly in Urwid. If you'd like to try 
it, read the curses_display module source code to see how it stores the 
attribute to colour pair mapping, and fill that data structure yourself.

It might not be the best project for introducing yourself to Python 
programming, but it is possible.

Now, doing a complete Urwid version of lfm would be fun.  But I'm sure 
my idea of fun differs from most peoples' :-)


More information about the Urwid mailing list