From 4cc4eae3671f9a8f9246f2bfbdeb1a5790cdb1f3 Mon Sep 17 00:00:00 2001 From: Jeremy Stanley Date: Sat, 16 May 2015 15:40:32 +0000 Subject: [PATCH] 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 --- gertty/mywid.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/gertty/mywid.py b/gertty/mywid.py index 364ea1f..1ef29c6 100644 --- a/gertty/mywid.py +++ b/gertty/mywid.py @@ -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']