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:
parent
758469ea0c
commit
4cc4eae367
@ -15,6 +15,7 @@
|
|||||||
import urwid
|
import urwid
|
||||||
|
|
||||||
from gertty import keymap
|
from gertty import keymap
|
||||||
|
from gertty.view import mouse_scroll_decorator
|
||||||
|
|
||||||
GLOBAL_HELP = (
|
GLOBAL_HELP = (
|
||||||
(keymap.HELP,
|
(keymap.HELP,
|
||||||
@ -73,6 +74,7 @@ class Table(urwid.WidgetWrap):
|
|||||||
for i, widget in enumerate(cells):
|
for i, widget in enumerate(cells):
|
||||||
self._w.contents[i][0].contents.append((widget, ('pack', None)))
|
self._w.contents[i][0].contents.append((widget, ('pack', None)))
|
||||||
|
|
||||||
|
@mouse_scroll_decorator.ScrollByWheel
|
||||||
class ButtonDialog(urwid.WidgetWrap):
|
class ButtonDialog(urwid.WidgetWrap):
|
||||||
def __init__(self, title, message, entry_prompt=None, entry_text='', buttons=[]):
|
def __init__(self, title, message, entry_prompt=None, entry_text='', buttons=[]):
|
||||||
button_widgets = []
|
button_widgets = []
|
||||||
@ -88,9 +90,8 @@ class ButtonDialog(urwid.WidgetWrap):
|
|||||||
self.entry = None
|
self.entry = None
|
||||||
rows.append(urwid.Divider())
|
rows.append(urwid.Divider())
|
||||||
rows.append(button_columns)
|
rows.append(button_columns)
|
||||||
pile = urwid.Pile(rows)
|
listbox = urwid.ListBox(rows)
|
||||||
fill = urwid.Filler(pile, valign='top')
|
super(ButtonDialog, self).__init__(urwid.LineBox(listbox, title))
|
||||||
super(ButtonDialog, self).__init__(urwid.LineBox(fill, title))
|
|
||||||
|
|
||||||
class TextEditDialog(urwid.WidgetWrap):
|
class TextEditDialog(urwid.WidgetWrap):
|
||||||
signals = ['save', 'cancel']
|
signals = ['save', 'cancel']
|
||||||
|
Loading…
x
Reference in New Issue
Block a user