PATRICK ROBERTS'S BLOG

egoFile.com/blog: Formalizing Intelligence in Code

Mon, 23 Aug 2004

Responsive User Interfaces

For the egoClip project, I aim to make the UI completely responsive. (By responsive, I mean that the UI never locks up and provides at least partial results ASAP, not that every operation is completed instantaneously.) I've used what I imagine is the standard/obvious approach:

Yesterday, a customer pointed out that in egoClip, when focused on the news item list control, if you hold down an arrow key to swiftly step through the items, it just leaps to an item when you release the key. The problem seemed to be that the time to show an item's text was greater than the key repeat rate. You could have a similar problem with a live search field.

So I wrote a little wxPython function that makes it easy to delay responding to the user's actions until they finish or pause. Here's the open-sourced code from egoClip: wxtimers.py. Example usage:

from wxtimers import wxDoLater

def event_handler(what_the_user_wants):
    wxDoLater(0.5, lambda: show(what_the_user_wants))

So if within half a second, the user asks you to show something else, the original do-later will be cancelled and the new one will start.

The module also contains my trivial convenience subclass of wxTimer.

permanent link

©2004-2008 Patrick Roberts | Burlington, Ontario, Canada