[Urwid] Tab focus changing, Radio buttons, Illuminating buttons

Ian Ward ian at excess.org
Tue Nov 15 17:33:50 EST 2005

antonio araujo wrote:

>Here Antonio.
>I send you a working version of RecordEditor, my urwid-based database editor.
>Now, I need some help to achieve more funcionality, and to resolve
>various problems with the interface.
>I think urwid is very nice, but very dificult and very "low level" api.
You're right, Urwid is very low level compared to most user interface 
libraries. I have tried to focus on carefully designing the low level 
elements so that almost any console interface can be built on top of it.

One person has requested that I make the dialog.py example program part 
of the library itself, and I will look at doing something like that, so 
that everyone won't have to write their own version of the same "message 
box" function.

Also, I might make 'tab' and 'shift tab' move between widgets by 
default, as this would be unsurprising to most users.

>My questions:
>- Can I do a floating dialog to alert the user with messages?
Yes, Urwid 0.8.9 has an Overlay class that you can use to create a 
dialog that floats above other screen content.  I wrote the dialog.py 
example before the Overlay class, so it doesn't use it, but you can see 
which widgets dialog.py uses to build a message box, then use Overlay to 
float your message box.

>- There is any method to include a non editable component in a list of
>editable components and achieve the focus for the rest?
You can include any flow widget in your ListBox, including Text widgets. 
If you do then your "select next item" code will have to change to 
something like:

widget, position = self.listbox.get_focus()
while True:
    self.listbox.set_focus( (position +1) % len(self.listbox_contents) )
    widget, position = self.listbox.get_focus()
    if widget.selectable(): break

>- Can I do a select of the field data when the field gain the focus?
This is a feature I want to add back to Urwid.  I removed it shortly 
before I made the first public release because of an incompatibility.  
I'll post some code that will select all the text in an Edit widget shortly.


>Ok for now.
>Thank you very mutch for urwid.

More information about the Urwid mailing list