Added selectionDialog.py

This commit is contained in:
Lamisator
2017-08-05 00:29:52 +02:00
parent 5f6b58e594
commit 81ff648312

35
src/selectionDialog.py Normal file
View File

@@ -0,0 +1,35 @@
import urwid
import sys
class fileIndexer(object):
def menu(self, title, choices):
body = [urwid.Text(title), urwid.Divider()]
for c in choices:
button = urwid.Button(c)
urwid.connect_signal(button, 'click', self.item_chosen, c)
body.append(urwid.AttrMap(button, None, focus_map='reversed'))
return urwid.ListBox(urwid.SimpleFocusListWalker(body))
def item_chosen(self, button, choice):
self.choice = choice
response = urwid.Text([u'You chose ', choice, u'\n'])
done = urwid.Button(u'Ok')
urwid.connect_signal(done, 'click', self.exit_program)
self.mainpd.original_widget = urwid.Filler(urwid.Pile([response,
urwid.AttrMap(done, None, focus_map='reversed')]))
def exit_program(self, button):
raise urwid.ExitMainLoop()
def __init__ (self, title, choices):
self.mainpd = urwid.Padding(self.menu(title, choices), left=2, right=2)
self.top = urwid.Overlay(self.mainpd, urwid.SolidFill(u'\N{MEDIUM SHADE}'),
align='center', width=('relative', 60),
valign='middle', height=('relative', 60),
min_width=20, min_height=9)
def start(self):
urwid.MainLoop(self.top, palette=[('reversed', 'standout', '')]).run()
return self.choice