[Urwid] multiple edit fields
Ian Ward
ian at excess.org
Thu Jun 22 09:56:03 EDT 2006
Eric S. Johansson wrote:
> I'm writing a ethernet manipulation utility for the IPCop project and
> I'm running into some problems. Problem number one is selecting which
> ethernet card I am using. I am using radio buttons because they kind of
> works as a user interface. The only question is how do I detect which
> button is currently active? I see it as a callback function and I can
> obviously use that to change the data structures holding the per network
> interface data. My question would be which do I need to kick off
> another display update or will that happen automatically after I return
> from the callback?
I've intentionally left Urwid pretty simple with respect to updates. If
you want to change the contents of the screen just modify the widgets
that you call render() on. In your case you need to change the text in
the edit widgets, or replace the edit widgets when the user selects a
new radio button.
The tour example just creates a bunch of widgets and puts them in a
ListBox. What you need to do is create your Edit widgets first, keep a
variable to reference them, then add them to the ListBox. That way you
can use your variables and set_edit_text() to change what they are
displaying.
> the second problem is the right hand column. Those are individual edit
> fields so I can change the IP address, network driver etc. but I'm not
> really sure how to retrieve the data so I can change the internal
> structures and save when the user hits the "not yet created" save button.
If you have variables to reference each of the Edit widgets you can get
the text that the user has entered with get_edit_text()
> I had another problem with the list of edit boxes, when I hit page down
> key it went from the radio boxes to the last edit box. I would have
> expected it to go to the first.
The ListBox widget takes page down to mean roughly "move my cursor one
screen down", similar to a text editor or web browser. You can change
this behavior by capturing page up/down keypresses when they are
returned from get_input() and making them do something else.
Hope this helps.
Ian
More information about the Urwid
mailing list