-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
executable file
·67 lines (46 loc) · 1.34 KB
/
main.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
from UserInterface import MenuItem
from UserInterface import MenuAction
from curses import wrapper
import curses.ascii
import math
import logging
_logger = logging.getLogger(__name__)
def configure_logger():
"""
setup basic logger config
"""
logging.basicConfig(level=logging.DEBUG,
filename="test",
format='%(asctime)s:%(levelname)s:%(filename)s:%(lineno)d:%(message)s')
def show_menu(stdscr, menu):
"""
:type stdscr: curses window object
"""
menu_start_height = math.floor((stdscr.getmaxyx()[0] - len(menu))/2)
menu_item_number = 0
for menu_item in menu:
stdscr.addstr(menu_start_height+menu_item_number, 0, menu_item.title)
menu_item_number += 1
stdscr.refresh()
def main(stdscr):
"""
:type stdscr: curses window object
"""
configure_logger()
_logger.debug("Oh Hai!")
m = MenuItem('test', 'test')
menu = {m}
# Clear screen
stdscr.clear()
show_menu(stdscr, menu)
while 1:
c = stdscr.getch()
if c == ord('q'):
_logger.debug("You hit q")
break # Exit the while()
elif c == curses.KEY_HOME:
_logger.debug("You hit Home")
else:
_logger.debug("burp")
#stdscr.getkey()
wrapper(main)