Mercurial > urwid-satext
comparison examples/menu.py @ 66:287ff3e1edd1
removed trailing spaces
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 21 Dec 2013 16:51:14 +0100 |
parents | e49d8f289a73 |
children | 6689aa54b20c |
comparison
equal
deleted
inserted
replaced
65:090f3e0754d3 | 66:287ff3e1edd1 |
---|---|
19 def __init__(self): | 19 def __init__(self): |
20 _frame = urwid.Frame(urwid.Filler(urwid.Text('Menu demo', align='center'))) | 20 _frame = urwid.Frame(urwid.Filler(urwid.Text('Menu demo', align='center'))) |
21 self.loop = urwid.MainLoop(_frame, const_PALETTE, unhandled_input=self.keyHandler) | 21 self.loop = urwid.MainLoop(_frame, const_PALETTE, unhandled_input=self.keyHandler) |
22 _frame.set_header(self.buildMenu()) | 22 _frame.set_header(self.buildMenu()) |
23 _frame.set_focus('header') | 23 _frame.set_focus('header') |
24 | 24 |
25 def run(self): | 25 def run(self): |
26 self.loop.run() | 26 self.loop.run() |
27 | 27 |
28 def _messageExit(self, message): | 28 def _messageExit(self, message): |
29 #We print the menu data in the middle of the screen | 29 #We print the menu data in the middle of the screen |
50 self.menu.addMenu(_menu1, "Exit (C-x)", self.exit_cb, 'ctrl x') #You can also add a shortcut | 50 self.menu.addMenu(_menu1, "Exit (C-x)", self.exit_cb, 'ctrl x') #You can also add a shortcut |
51 _menu2 = "Menu 2" | 51 _menu2 = "Menu 2" |
52 self.menu.addMenu(_menu2, "Item 1", self.menu_cb) | 52 self.menu.addMenu(_menu2, "Item 1", self.menu_cb) |
53 self.menu.addMenu(_menu2, "Item 2", self.menu_cb) | 53 self.menu.addMenu(_menu2, "Item 2", self.menu_cb) |
54 self.menu.addMenu(_menu2, "Item 3", self.menu_cb) | 54 self.menu.addMenu(_menu2, "Item 3", self.menu_cb) |
55 return self.menu | 55 return self.menu |
56 | 56 |
57 def keyHandler(self, input): | 57 def keyHandler(self, input): |
58 """We leave if user press a quit char""" | 58 """We leave if user press a quit char""" |
59 if input in ('esc','q','Q'): | 59 if input in ('esc','q','Q'): |
60 raise urwid.ExitMainLoop() | 60 raise urwid.ExitMainLoop() |