Leif Theden wrote:
> Greetings!  I am a first time user of urwid.  I was wondering if
> anyone has attempted animation of widgets before?
> 
> I have looked at the graph.py example, and I don't think that that is
> what exactly I am looking for.
> 
> I have an individual widget that displays a dungeon map from a game,
> and I would like to have the rendering function animated, and possibly
> animated characters while the widget is being viewed.
> 
> My current implimentation simply diables caching and renders the
> canvas over and over, creating animation.  It works, but since it is
> grossly ineffecient, I wanted to ask people who may know a better way.

Animation is just changing the contents widgets at regular intervals.
If you have a widget that changes say, every 0.5 seconds, you could set
max_wait to 0.25 with screen.set_input_timeouts() and each time through
your loop you calculate which state the widget should be in based on the
current time.  If the widget is changed make sure it calls its
self._invalidate() method.

This way the widget will still use its cache and not update when it
doesn't need to, and you can easily have many widgets animating at
different rates.

Ian



_______________________________________________
Urwid mailing list
[email protected]
http://lists.excess.org/mailman/listinfo/urwid

Reply via email to