From dcc2222816a3f82a60d4b7dfe620348abcf07f97 Mon Sep 17 00:00:00 2001 From: Michael Spang Date: Tue, 27 Sep 2011 09:38:03 -0400 Subject: [PATCH] Fix default selection of next button This used to work until urwid tried to start becoming smart about which widget gets focus. Revert back to the dumb behavior. --- ceo/urwid/widgets.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/ceo/urwid/widgets.py b/ceo/urwid/widgets.py index 232e9a0..fd17172 100644 --- a/ceo/urwid/widgets.py +++ b/ceo/urwid/widgets.py @@ -157,6 +157,15 @@ class EnhancedButton(urwid.Button): else: return urwid.Button.keypress(self, size, key) +class DumbColumns(urwid.Columns): + """Dumb columns widget + + The normal one tries to focus the "nearest" widget to the cursor. + This makes the Back button default instead of the Next button. + """ + def move_cursor_to_coords(self, size, col, row): + pass + class Wizard(urwid.WidgetWrap): def __init__(self): self.selected = None @@ -165,7 +174,7 @@ class Wizard(urwid.WidgetWrap): self.panelwrap = urwid.WidgetWrap( urwid.SolidFill() ) self.back = EnhancedButton("Back", self.back) self.next = EnhancedButton("Next", self.next) - self.buttons = urwid.Columns( [ self.back, self.next ], dividechars=3, focus_column=1 ) + self.buttons = DumbColumns( [ self.back, self.next ], dividechars=3, focus_column=1 ) pad = urwid.Padding( self.buttons, ('fixed right', 2), 19 ) self.pile = urwid.Pile( [self.panelwrap, ('flow', pad)], 0 ) urwid.WidgetWrap.__init__(self, self.pile)