[Urwid] Documentation or example on how the Signals class is used?

Ian Ward ian at excess.org
Sun Jun 28 09:15:50 EDT 2009


Dominic LoBue wrote:
> Thanks a lot. I figured out how to use your Signals class since I sent
> that message by creating some small simple examples and reading
> through the code, and I'm loving it. Brilliant implementation. Gave me
> an idea on how to create a buffer manager for my application :)

Thanks.  One thing I want to improve is matching the function signature 
at register and connect time.  It's pretty common to get the parameters 
wrong and not find out until the signal is actually sent, and a little 
parameter introspection could solve that.

I was also thinking about how to improve the MetaSignals metaclass. 
Right now you can just declare a list of signals, but something like 
this would be nice:

class Foo:
     __metaclass__ = MetaSignals

     class Signals:
         # signals Foo may emit, with signatures and docstrings
         def modified(foo):
             "foo object has been changed"
         def frob(foo, value, urgent=False):
             "foo has frobbed"

     def do_something(self, value):
         self._emit.frob(value)
         self._emit.modified()

> 
> On the subject of bettering documentation, could you do a writeup on
> the site on how urwid's caching works? I'd like to be able to work
> with the caching system from the start, rather than find out down the
> road I'm creating more work for myself (and my cpu) then was
> necessary.

That's a good suggestion.  I'm sure there are still some bugs in the way 
many widgets are working with the cache, and documenting correct usage 
could only help.

If you are making your own widget classes (with your own render methods, 
  WidgetWrap subclasses don't count) then the only thing you should have 
to know it to call _invalidate when the content of your widget changes.

> Also I found a bug in the monitored list class. I was unable to sent
> keyword arguments to sort. Here's a diff with the fix:

Thanks!  Please send it again with hg export so that your name is on the 
patch.

Ian




More information about the Urwid mailing list