bpeterso2000
7/28/2014 - 3:14 PM

Sample use of "Text Menu" snippet

Sample use of "Text Menu" snippet

from demo.menu import Menu
from search import Search


class SearchDemo:

    def __init__(self):
        self.search = Search()

    def search(self):
        pass

    def clear_filter(self):
        pass

    def show_facets(self):
        pass

    def show_result_summary(self):
        pass

    def set_items_per_page(self):
        pass

    def show_first_page(self):
        pass

    def show_next_page(self):
        pass

    def show_previous_page(self):
        pass

    def show_last_page(self):
        pass

    def main_menu(self):
        while True:
            options = [
                'Search',
                'Set Filter',
                'Clear Filter',
                'Show Facets',
                'Show Result Summary',
                'Set Items per Page',
                'Show First Page',
                'Show Next Page',
                'Show Previous Page',
                'Show Last Page'
            ]
            menu = Menu(options, title='Search Demo:', exit_on_quit=True)
            _, item = menu.select()
            print()
            getattr(self, item.lower().replace(' ', '_'))()


def begin():
    SearchDemo().main_menu()

if __name__ == '__main__':
    begin()