forked from spatil47/car
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinterface.py
80 lines (55 loc) · 2.05 KB
/
interface.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
68
69
70
71
72
73
74
75
76
77
78
79
80
import urwid
import random
class ItemWidget (urwid.WidgetWrap):
def __init__ (self, id, description):
self.id = id
self.content = 'item %s: %s...' % (str(id), description[:25])
self.item = [
('fixed', 15, urwid.Padding(urwid.AttrWrap(
urwid.Text('item %s' % str(id)), 'body', 'focus'), left=2)),
urwid.AttrWrap(urwid.Text('%s' % description), 'body', 'focus'),
]
w = urwid.Columns(self.item)
self.__super.__init__(w)
def selectable (self):
return True
def keypress(self, size, key):
return key
class MainLayoutWidget (urwid.WidgetWrap):
def __init__ (self, id, description):
self.id = id
self.content = 'item %s: %s...' % (str(id), description[:25])
self.item = [
urwid.LineBox(urwid.Text('vvvvvvvvvvvvvv')),
urwid.LineBox(urwid.Text('vvvvvvvvvvvvvv'))
]
w = urwid.Columns(self.item)
self.__super.__init__(w)
def keypress(self, size, key):
return key
def main ():
palette = [
('body','dark cyan', '', 'standout'),
('focus','dark red', '', 'standout'),
('head','light red', 'black'),
]
lorem = [
'Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
'Sed sollicitudin, nulla id viverra pulvinar.',
'Cras a magna sit amet felis fringilla lobortis.',
]
def keystroke (input):
if input in ('q', 'Q'):
raise urwid.ExitMainLoop()
#if input is 'enter':
# focus = listbox.get_focus()[0].content
# view.set_header(urwid.AttrWrap(urwid.Text(
# 'selected: %s' % str(focus)), 'head'))
header = urwid.AttrMap(urwid.Text('Main Menu'), 'head')
mainwidget = urwid.LineBox(MainLayoutWidget(1,'t'))
fill = urwid.Filler(mainwidget, 'middle')
view = urwid.Frame(fill, header = header)
loop = urwid.MainLoop(view)
loop.run()
if __name__ == '__main__':
main()