[Urwid] radio button magic
Ian Ward
ian at excess.org
Tue Jul 25 10:26:24 EDT 2006
Eric S. Johansson wrote:
> For what it's worth, the only time I change the radio buttons is when I
> change the configuration return to me in a different part of the user
> interface. Which reminds me, what's the best way of implementing a
> selection box? I'm currently using an edit box where the user edits the
> number to select a different configuration.
The closest I've seen is Rebecca's example program that creates
drop-down menus:
http://excess.org/urwid/rbreu_menus.py
I'm planning to make some changes to Canvas that will let you "pop up"
windows to do selection boxes etc, but it's not very easy to do right now.
> failing a simple solution,
> how about what is the best way to get just what the user has typed and
> not the entire contents of the edit box? again, I just need a simple
> single character integer 0-7.
You could make a widget that has a keypress() function, eg:
class SelectionThing(urwid.WidgetWrap):
def __init__(self):
urwid.WidgetWrap.__init__(self, urwid.Text("Press 0-7"))
def keypress(self, size, key):
if key in list("01234567"):
# do something
return None
return key
Ian
More information about the Urwid
mailing list