Begin work on new urwid interface.
This commit is contained in:
parent
17c7938858
commit
a2829333fc
1 changed files with 19 additions and 23 deletions
42
newfol
42
newfol
|
|
@ -56,29 +56,25 @@ def convert_color(x):
|
|||
locale.setlocale(locale.LC_ALL, '')
|
||||
|
||||
def start_curses():
|
||||
try:
|
||||
mainwin = curses.initscr()
|
||||
curses.start_color()
|
||||
attr = 0
|
||||
if curses.has_colors() and curses.can_change_color():
|
||||
curses.start_color()
|
||||
curses.use_default_colors()
|
||||
curses.init_color(22, convert_color(0xee), convert_color(0xd6),
|
||||
convert_color(0x80))
|
||||
curses.init_color(23, convert_color(0x66), convert_color(0x38),
|
||||
convert_color(0x22))
|
||||
curses.init_pair(1, 23, 22)
|
||||
attr = curses.color_pair(1)
|
||||
mainpanel = curses.panel.new_panel(mainwin)
|
||||
mainpanel.show()
|
||||
curses.panel.update_panels()
|
||||
mainwin.addstr("Hello, world!", attr)
|
||||
curses.doupdate()
|
||||
mainwin.getch()
|
||||
curses.endwin()
|
||||
except Exception as e:
|
||||
curses.endwin()
|
||||
raise e
|
||||
palette = [
|
||||
('bg', 'black', 'yellow', '', 'black', '#ffa'),
|
||||
('text', 'black', 'yellow', '', '#860', '#ffa'),
|
||||
]
|
||||
intro1 = urwid.Text(("text", "newfol " + __version__), align="center")
|
||||
intro2 = urwid.Text(("text", "Press q to quit at any time."),
|
||||
align="center")
|
||||
pile = urwid.Pile([
|
||||
urwid.AttrMap(intro1, "bg"),
|
||||
urwid.AttrMap(intro2, "bg")])
|
||||
fill = urwid.Filler(pile)
|
||||
map2 = urwid.AttrMap(fill, "bg")
|
||||
|
||||
def exit_on_q(inp):
|
||||
if inp in ('q', 'Q'):
|
||||
raise urwid.ExitMainLoop()
|
||||
loop = urwid.MainLoop(map2, palette, unhandled_input=exit_on_q)
|
||||
loop.screen.set_terminal_properties(colors=256)
|
||||
loop.run()
|
||||
|
||||
def load_schemata():
|
||||
vault = filemanip.FileStorage('csv', os.path.expanduser("~/.newfol/schema"))
|
||||
|
|
|
|||
Loading…
Reference in a new issue