forked from npcole/npyscreen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
testtitlewidget.py
37 lines (24 loc) · 886 Bytes
/
testtitlewidget.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import npyscreen
import curses
class TestTitleText(widget.Widget):
_entry_type = textbox.Textfield
class TestTitleWidget(npyscreen.TitleText):
def set_up_handlers(self):
self.handlers = {
curses.ascii.NL: self.h_exit_down,
curses.ascii.CR: self.h_exit_down,
curses.ascii.TAB: self.h_exit_down,
curses.KEY_BTAB: self.h_exit_up,
curses.KEY_DOWN: self.h_exit_down,
curses.KEY_UP: self.h_exit_up,
curses.KEY_LEFT: self.h_exit_left,
}
def h_exit_down(self, h):
self.exit_up()
def TitleTest(screen):
F = npyscreen.Form()
F.add(TestTitleWidget, name="Title 1")
F.add(TestTitleWidget, name="Title 2")
F.edit()
if __name__ == "__main__":
curses.wrapper(TitleTest)