[Urwid] Enable/disable buttons?

Yasir Assam mail at endlessvoid.com
Mon Dec 7 02:53:47 EST 2009


I'm new to urwid. I'm trying to create a simple dialog as follows:

import urwid

f1 = urwid.Edit("Field 1: ")
f2 = urwid.Edit("Field 2: ")
f3 = urwid.Edit("Field 3: ")

ok = urwid.Button("OK")
cancel = urwid.Button("Cancel")

gf = urwid.GridFlow([ok, cancel], 10, 10, 0, "center")

pile = urwid.Pile([
        f1,
        f2,
        f3,
        urwid.Divider(),
        gf
        ])

fill = urwid.Filler(pile, valign="top")

loop = urwid.MainLoop(fill)
loop.run()


I want to be able to disable the OK button depending on what's being 
input. By "disable" I stopping the cursor from moving it to it when I 
use the arrow keys to move focus around.

Is there an easy way to do this?

Thanks,
Yasir
-------------- next part --------------

No virus found in this outgoing message.
Checked by AVG - www.avg.com 
Version: 8.5.426 / Virus Database: 270.14.96/2549 - Release Date: 12/06/09 19:37:00


More information about the Urwid mailing list