[Urwid] detecting when an edit box has changed
Ian Ward
ian at excess.org
Sat Jul 15 11:06:46 EDT 2006
Derek Peschel wrote:
> On Fri, Jul 07, 2006 at 11:36:09PM -0400, Ian Ward wrote:
>> Eric S. Johansson wrote:
>>
>>> is there any way to detect when an edit box has changed short of
>>> comparing against some "original" data source?
>> You can hook its keypress() function and check if it returned None
>> (which means that the key was handled by the edit widget. To do that you
>> can either subclass the Edit widget or the WidgetWrap class to define
>> your own keypress function.
>
> I swore I'd let urwid wait for a day or two, but people keep addressing
> topics I've also been thinking about.
>
> All keypresses don't create changed text; some just move the cursor. Even
> the keystrokes that you expect to change text (like backspace) don't always,
> as when you backspace at the beginning of the text.
With Urwid 0.9.5 you can now hook the set_edit_text() function to
capture all changes to the text in an Edit widget.
Hope this helps!
Ian
More information about the Urwid
mailing list