[Urwid] placing buttons and widgets

Ian Ward ian at excess.org
Wed Oct 4 14:23:43 EDT 2006

Fabian Braennstroem wrote:
> Hi,
> I just tried out Rebecca's filechooser and was asking
> myself, if it is somehow possible to place certain 'things',
> e.g. the buttons or 'hidden-file-checkbox' at the last line
> of the window? Right now, it is placed below the directory
> and file widget, but does not have an 'absolute' position.
> A corresponding problem would be to adjust the height of the
> file and directory widgets according to the window size.
> This in fact would solve my above problem ...

The old way of placing something at the top or bottom of a box widget is 
with the Frame widget, however, your focus will not move from the box 
widget to the frame widget just by pressing the arrow keys.  If you want 
part of the UI to be below a box widget you can use the Pile widget like 

boxwidget = a ListBox or something
buttons = a Pile, Columns or GridFlow widget containing buttons
box_and_buttons = Pile([boxwidget, ('flow', buttons)])

then box_and_buttons should be treated as a box widget and it will 
display buttons at the bottom, leaving the rest of the space for boxwidget.

> And one more question ... Would it somehow be possible to
> create some kind of a notebook (like glade-2 is calling it)
> or tabs (like lfm is calling it)? Maybe, it is possible to
> place some widget behind each other?

The best way to do that would be to keep a widget for each page and 
create a set of buttons that will change which widget is displayed.  Use 
WidgetWrap to wrap a Pile widget and it shouldn't be too hard to do what 
you're looking for.



More information about the Urwid mailing list