Make ButtonDialog scrollable

When there are more rows than will fit in a ButtonDialog Linebox,
having them wrapped within a ListBox makes it possible to scroll
through them rather than merely displaying the last lines.

Change-Id: Id38fb999e2eceda03bc15d0928765acb936dd8c8
This commit is contained in:
Jeremy Stanley 2015-05-16 15:40:32 +00:00
parent 758469ea0c
commit 4cc4eae367
1 changed files with 4 additions and 3 deletions

View File

@ -15,6 +15,7 @@
import urwid
from gertty import keymap
from gertty.view import mouse_scroll_decorator
GLOBAL_HELP = (
(keymap.HELP,
@ -73,6 +74,7 @@ class Table(urwid.WidgetWrap):
for i, widget in enumerate(cells):
self._w.contents[i][0].contents.append((widget, ('pack', None)))
@mouse_scroll_decorator.ScrollByWheel
class ButtonDialog(urwid.WidgetWrap):
def __init__(self, title, message, entry_prompt=None, entry_text='', buttons=[]):
button_widgets = []
@ -88,9 +90,8 @@ class ButtonDialog(urwid.WidgetWrap):
self.entry = None
rows.append(urwid.Divider())
rows.append(button_columns)
pile = urwid.Pile(rows)
fill = urwid.Filler(pile, valign='top')
super(ButtonDialog, self).__init__(urwid.LineBox(fill, title))
listbox = urwid.ListBox(rows)
super(ButtonDialog, self).__init__(urwid.LineBox(listbox, title))
class TextEditDialog(urwid.WidgetWrap):
signals = ['save', 'cancel']